pause if no space rather than remove
This commit is contained in:
parent
61e48e249b
commit
1a53039d1a
|
@ -637,6 +637,7 @@ class Manager:
|
|||
##
|
||||
def sync(self):
|
||||
ret = None # We return new added unique ID(s), or None
|
||||
no_space = False
|
||||
|
||||
# Add torrents to core and unique_IDs
|
||||
torrents_with_unique_ID = self.unique_IDs.values()
|
||||
|
@ -653,18 +654,14 @@ class Manager:
|
|||
avail = self.calc_free_space(torrent.save_dir)
|
||||
print "Torrent Size", size
|
||||
print "Available Space", avail
|
||||
size = avail + 1 #debug!
|
||||
# size = avail + 1 #debug!
|
||||
if size > avail: # Not enough free space
|
||||
deluge_core.remove_torrent(unique_ID) #Remove the torrent
|
||||
self.state.torrents.remove(torrent)
|
||||
#self.state.queue.remove(unique_ID)
|
||||
os.remove(torrent.filename)
|
||||
try:
|
||||
# Must be after removal of the torrent, because that saves a new .fastresume
|
||||
os.remove(torrent.filename + ".fastresume")
|
||||
except OSError:
|
||||
pass # Perhaps there never was one to begin with
|
||||
raise InsufficientFreeSpaceError(avail, size)
|
||||
torrent.user_paused = True
|
||||
no_space = True
|
||||
# deluge_core.remove_torrent(unique_ID) #Remove the torrent
|
||||
# self.state.torrents.remove(torrent)
|
||||
# os.remove(torrent.filename)
|
||||
# raise InsufficientFreeSpaceError(avail, size)
|
||||
ret = unique_ID
|
||||
self.unique_IDs[unique_ID] = torrent
|
||||
|
||||
|
@ -711,7 +708,10 @@ class Manager:
|
|||
assert(len(self.unique_IDs) == len(self.state.queue))
|
||||
assert(len(self.unique_IDs) == deluge_core.get_num_torrents())
|
||||
|
||||
return ret
|
||||
if no_space:
|
||||
self.apply_queue()
|
||||
|
||||
return ret, no_space
|
||||
|
||||
def get_queue_index(self, unique_ID):
|
||||
return self.state.queue.index(unique_ID)
|
||||
|
|
|
@ -675,14 +675,7 @@ class DelugeGTK:
|
|||
torrent_subdir = self.manager.base_dir + "/" + deluge.TORRENTS_SUBDIR
|
||||
for torrent in os.listdir(torrent_subdir):
|
||||
if torrent.endswith('.torrent'):
|
||||
if self.config.get('use_default_dir', bool, default=False):
|
||||
path = self.config.get('default_download_path', default=os.path.expandvars('$HOME'))
|
||||
else:
|
||||
path = dgtk.show_directory_chooser_dialog(self.window,
|
||||
_("Choose the download directory for") + " " + torrent)
|
||||
if path is not None:
|
||||
unique_id = self.manager.add_old_torrent(torrent, path, self.config.get('use_compact_storage', bool, default=False))
|
||||
self.torrent_model.append(self.get_list_from_unique_id(unique_id))
|
||||
self.interactive_add_torrent(torrent)
|
||||
self.something_screwed_up = False
|
||||
|
||||
# Update Statusbar and Tray Tips
|
||||
|
@ -879,20 +872,13 @@ class DelugeGTK:
|
|||
path = dgtk.show_directory_chooser_dialog(self.window)
|
||||
if path is None:
|
||||
return
|
||||
try:
|
||||
unique_id = self.manager.add_torrent(torrent, path, False)
|
||||
# unique_id = self.manager.add_torrent(torrent, path, self.config.get('use_compact_storage', bool, default=False))
|
||||
except deluge.InsufficientFreeSpaceError, err:
|
||||
print "Got an Error,", err
|
||||
if self.is_running: # make sure the gui is running and alert the user.
|
||||
nice_need = dcommon.fsize(err.needed_space)
|
||||
nice_free = dcommon.fsize(err.free_space)
|
||||
message = _("There is not enough free disk space to complete your download.") + "\n" \
|
||||
+ _("Space available on disk:") + " " + nice_free + "\n" \
|
||||
+ _("Total size of download:") + " " + nice_need
|
||||
dgtk.show_popup_warning(self.window, message)
|
||||
|
||||
return
|
||||
# unique_id = self.manager.add_torrent(torrent, path, self.config.get('use_compact_storage', bool, default=False))
|
||||
(unique_id, paused) = self.manager.add_torrent(torrent, path, False)
|
||||
# nice_need = dcommon.fsize(err.needed_space)
|
||||
# nice_free = dcommon.fsize(err.free_space)
|
||||
dgtk.show_popup_warning(self.window, _("There is not enough free space to complete this download.") + \
|
||||
_("Please ensure you have enough space available, then unpause the download."))
|
||||
|
||||
if append:
|
||||
self.torrent_model.append(self.get_list_from_unique_id(unique_id))
|
||||
|
|
Loading…
Reference in New Issue