From 3bf6b9896c2fd2fd6d30cdc5aa49e8c26e3b8428 Mon Sep 17 00:00:00 2001 From: Jens Luetjen Date: Sat, 6 Feb 2016 16:22:54 +0100 Subject: [PATCH] Limit history to 500 track To avoid an too large history list, save/restore maximum 500 tracks. 500 tracks a 3 minuts gives 24 hours history. --- mopidy/core/history.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mopidy/core/history.py b/mopidy/core/history.py index 3c0a2446..a6b4c817 100644 --- a/mopidy/core/history.py +++ b/mopidy/core/history.py @@ -60,10 +60,18 @@ class HistoryController(object): def _export_state(self): """Internal method for :class:`mopidy.Core`.""" + + # 500 tracks a 3 minutes -> 24 hours history + count_max = 500 + count = 1 history_list = [] for timestamp, track in self._history: history_list.append(HistoryTrack( timestamp=timestamp, track=track)) + count += 1 + if count_max < count: + logger.info('Limit history to %s tracks.', count_max) + break return HistoryState(history=history_list) def _restore_state(self, state, coverage):