Save torrent state every 5 minutes.

This commit is contained in:
Andrew Resch 2007-10-03 02:57:05 +00:00
parent a17328fff7
commit 170c3810b3
2 changed files with 8 additions and 2 deletions

2
TODO
View File

@ -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!

View File

@ -37,6 +37,8 @@ import pickle
import os.path
import os
import gobject
import deluge.libtorrent as lt
import deluge.common
@ -76,6 +78,9 @@ class TorrentManager:
# 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",
self.on_set_max_connections_per_torrent)
@ -318,6 +323,9 @@ class TorrentManager:
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"""
torrent = self.torrents[torrent_id]