diff --git a/TODO b/TODO index 305832816..f649136f3 100644 --- a/TODO +++ b/TODO @@ -14,6 +14,4 @@ to add menuitems to the torrentmenu in an easy way. * Restart daemon function * Sync the details pane to current trunk -* Automatically save torrent state every ~5 minutes, much like how - configmanager does it. * Docstrings! diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 5a50fb3e1..04dbbdd17 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -37,6 +37,8 @@ import pickle import os.path import os +import gobject + import deluge.libtorrent as lt import deluge.common @@ -75,6 +77,9 @@ class TorrentManager: self.torrents = {} # Try to load the state from file self.load_state() + + # Save the state every 5 minutes + self.save_state_timer = gobject.timeout_add(300000, self.save_state) # Register set functions self.config.register_set_function("max_connections_per_torrent", @@ -317,6 +322,9 @@ class TorrentManager: state_file.close() except IOError: log.warning("Unable to save state file.") + + # We return True so that the timer thread will continue + return True def delete_fastresume(self, torrent_id): """Deletes the .fastresume file"""