Fix issue where fastresume is not being saved properly on shutdown when
using compact allocation
This commit is contained in:
parent
5cbf606503
commit
67d156973c
|
@ -114,6 +114,11 @@ class TorrentManager(component.Component):
|
||||||
# Create the torrents dict { torrent_id: Torrent }
|
# Create the torrents dict { torrent_id: Torrent }
|
||||||
self.torrents = {}
|
self.torrents = {}
|
||||||
|
|
||||||
|
# This is a list of torrent_id when we shutdown the torrentmanager.
|
||||||
|
# We use this list to determine if all active torrents have been paused
|
||||||
|
# and that their resume data has been written.
|
||||||
|
self.shutdown_torrent_pause_list = []
|
||||||
|
|
||||||
# Register set functions
|
# Register set functions
|
||||||
self.config.register_set_function("max_connections_per_torrent",
|
self.config.register_set_function("max_connections_per_torrent",
|
||||||
self.on_set_max_connections_per_torrent)
|
self.on_set_max_connections_per_torrent)
|
||||||
|
@ -158,8 +163,13 @@ class TorrentManager(component.Component):
|
||||||
def stop(self):
|
def stop(self):
|
||||||
# Save state on shutdown
|
# Save state on shutdown
|
||||||
self.save_state()
|
self.save_state()
|
||||||
|
|
||||||
|
component.pause("AlertManager")
|
||||||
for key in self.torrents.keys():
|
for key in self.torrents.keys():
|
||||||
|
if not self.torrents[key].handle.is_paused():
|
||||||
self.torrents[key].handle.pause()
|
self.torrents[key].handle.pause()
|
||||||
|
self.shutdown_torrent_pause_list.append(key)
|
||||||
|
while self.shutdown_torrent_pause_list:
|
||||||
# Wait for all alerts
|
# Wait for all alerts
|
||||||
self.alerts.handle_alerts(True)
|
self.alerts.handle_alerts(True)
|
||||||
|
|
||||||
|
@ -613,6 +623,9 @@ class TorrentManager(component.Component):
|
||||||
# Write the fastresume file
|
# Write the fastresume file
|
||||||
self.torrents[torrent_id].write_fastresume()
|
self.torrents[torrent_id].write_fastresume()
|
||||||
|
|
||||||
|
if torrent_id in self.shutdown_torrent_pause_list:
|
||||||
|
self.shutdown_torrent_pause_list.remove(torrent_id)
|
||||||
|
|
||||||
def on_alert_torrent_checked(self, alert):
|
def on_alert_torrent_checked(self, alert):
|
||||||
log.debug("on_alert_torrent_checked")
|
log.debug("on_alert_torrent_checked")
|
||||||
# Get the torrent_id
|
# Get the torrent_id
|
||||||
|
|
Loading…
Reference in New Issue