From 67e9787ba1e430b444994070abfb5d26fc2f12eb Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 16 Feb 2014 00:37:45 +0000 Subject: [PATCH] [#1923] Add pre-allocation and remove compact allocation Compact allocation is deprecated and a new pre-allocation is available. Any torrents already using compact will continue to do so but any newly added only can use sparse (default) or allocate options. The UIs have been updated to only display a checkbox in preferences for the user to enable 'Pre-allocate disk space'. --- deluge/core/preferencesmanager.py | 2 +- deluge/core/torrent.py | 18 ++-- deluge/core/torrentmanager.py | 34 ++++--- deluge/ui/console/modes/preference_panes.py | 6 +- deluge/ui/gtkui/addtorrentdialog.py | 47 +++------- deluge/ui/gtkui/files_tab.py | 6 +- deluge/ui/gtkui/glade/add_torrent_dialog.ui | 84 ++++------------- deluge/ui/gtkui/glade/preferences_dialog.ui | 89 ++++--------------- deluge/ui/gtkui/options_tab.py | 8 +- deluge/ui/gtkui/preferences.py | 20 ++--- .../ui/web/js/deluge-all/add/OptionsPanel.js | 36 ++------ deluge/ui/web/js/deluge-all/add/OptionsTab.js | 39 ++------ .../deluge-all/preferences/DownloadsPage.js | 40 ++------- 13 files changed, 110 insertions(+), 319 deletions(-) diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py index c2c128cdc..64991cea5 100644 --- a/deluge/core/preferencesmanager.py +++ b/deluge/core/preferencesmanager.py @@ -53,7 +53,7 @@ DEFAULT_PREFS = { "info_sent": 0.0, "daemon_port": 58846, "allow_remote": False, - "compact_allocation": False, + "pre_allocate_storage": False, "download_location": deluge.common.get_default_download_dir(), "listen_ports": [6881, 6891], "listen_interface": "", diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 642588124..c59e68b35 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -69,8 +69,7 @@ class TorrentOptions(dict): limit you set.The default is unlimited (-1) but will not exceed global limit. prioritize_first_last_pieces (bool): Prioritize the first and last pieces in the torrent. sequential_download (bool): Download the pieces of the torrent in order. - compact_allocation (bool): Use compact allocation instead of full allocation - for this torrent's data. + pre_allocate_storage (bool): When adding the torrent should all files be pre-allocated. download_location (str): The path for the torrent data to be stored while downloading. auto_managed (bool): Set torrent to auto managed mode, i.e. will be started or queued automatically. stop_at_ratio (bool): Stop the torrent when it has reached stop_ratio. @@ -97,7 +96,7 @@ class TorrentOptions(dict): "max_download_speed": "max_download_speed_per_torrent", "prioritize_first_last_pieces": "prioritize_first_last_pieces", "sequential_download": "sequential_download", - "compact_allocation": "compact_allocation", + "pre_allocate_storage": "pre_allocate_storage", "download_location": "download_location", "auto_managed": "auto_managed", "stop_at_ratio": "stop_seed_at_ratio", @@ -313,7 +312,7 @@ class Torrent(object): return if not self.has_metadata: return - if self.options["compact_allocation"]: + if self.get_status(["storage_mode"])["storage_mode"] == "compact": log.debug("Setting first/last priority with compact allocation does not work!") return # A list of priorities for each piece in the torrent @@ -348,8 +347,11 @@ class Torrent(object): Args: set_sequencial (bool): Enable sequencial downloading. """ - self.options["sequential_download"] = set_sequencial - self.handle.set_sequential_download(set_sequencial) + if self.get_status(["storage_mode"])["storage_mode"] != "compact": + self.options["sequential_download"] = set_sequencial + self.handle.set_sequential_download(set_sequencial) + else: + self.options["sequential_download"] = False def set_auto_managed(self, auto_managed): """Set auto managed mode, i.e. will be started or queued automatically. @@ -428,7 +430,7 @@ class Torrent(object): self.options["file_priorities"] = self.handle.file_priorities() return - if self.options["compact_allocation"]: + if self.get_status(["storage_mode"])["storage_mode"] == "compact": log.warning("Setting file priority with compact allocation does not work!") self.options["file_priorities"] = self.handle.file_priorities() return @@ -853,7 +855,7 @@ class Torrent(object): self.status_funcs = { "active_time": lambda: self.status.active_time, "all_time_download": lambda: self.status.all_time_download, - "compact": lambda: self.options["compact_allocation"], + "storage_mode": lambda: self.status.storage_mode.name.split("_")[2], # Returns: sparse, allocate or compact "distributed_copies": lambda: 0.0 if self.status.distributed_copies < 0 else self.status.distributed_copies, # Adjust status.distributed_copies to return a non-negative value "download_payload_rate": lambda: self.status.download_payload_rate, diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 67b4c21bc..d73f4c84f 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -67,7 +67,7 @@ class TorrentState: torrent_id=None, filename=None, trackers=None, - compact=False, + storage_mode="sparse", paused=False, save_path=None, max_connections=-1, @@ -100,7 +100,7 @@ class TorrentState: self.magnet = magnet # Options - self.compact = compact + self.storage_mode = storage_mode self.paused = paused self.save_path = save_path self.max_connections = max_connections @@ -347,7 +347,8 @@ class TorrentManager(component.Component): options["prioritize_first_last_pieces"] = state.prioritize_first_last options["sequential_download"] = state.sequential_download options["file_priorities"] = state.file_priorities - options["compact_allocation"] = state.compact + storage_mode = state.storage_mode + options["pre_allocate_storage"] = (storage_mode == "allocate") options["download_location"] = state.save_path options["auto_managed"] = state.auto_managed options["stop_at_ratio"] = state.stop_at_ratio @@ -362,6 +363,7 @@ class TorrentManager(component.Component): options["owner"] = state.owner options["name"] = state.name + torrent_info = self.get_torrent_info_from_file( os.path.join(self.state_dir, state.torrent_id + ".torrent")) if torrent_info: @@ -427,6 +429,11 @@ class TorrentManager(component.Component): except TypeError: torrent_info.rename_file(index, fname.encode("utf-8")) + if options["pre_allocate_storage"]: + storage_mode = "allocate" + else: + storage_mode = "sparse" + add_torrent_params["ti"] = torrent_info if log.isEnabledFor(logging.DEBUG): @@ -438,15 +445,13 @@ class TorrentManager(component.Component): if not account_exists: options["owner"] = "localclient" - # Set the right storage_mode - if options["compact_allocation"]: - storage_mode = lt.storage_mode_t(2) - else: - storage_mode = lt.storage_mode_t(1) - # Fill in the rest of the add_torrent_params dictionary add_torrent_params["save_path"] = utf8_encoded(options["download_location"]) - add_torrent_params["storage_mode"] = storage_mode + + try: + add_torrent_params["storage_mode"] = lt.storage_mode_t.names["storage_mode_" + storage_mode] + except KeyError: + add_torrent_params["storage_mode"] = lt.storage_mode_t.storage_mode_sparse default_flags = (lt.add_torrent_params_flags_t.flag_paused | lt.add_torrent_params_flags_t.flag_auto_managed | @@ -643,14 +648,17 @@ class TorrentManager(component.Component): if state is None: state = TorrentManagerState() - # Fixup an old state by adding missing TorrentState options and assigning them None + # Fixup an old state by adding missing TorrentState options and assigning default values try: if len(state.torrents) > 0: state_tmp = TorrentState() if dir(state.torrents[0]) != dir(state_tmp): for attr in (set(dir(state_tmp)) - set(dir(state.torrents[0]))): for s in state.torrents: - setattr(s, attr, getattr(state_tmp, attr, None)) + if attr == "storage_mode" and getattr(s, "compact", None): + setattr(s, attr, "compact") + else: + setattr(s, attr, getattr(state_tmp, attr, None)) except Exception, e: log.exception("Unable to update state file to a compatible version: %s", e) @@ -690,7 +698,7 @@ class TorrentManager(component.Component): torrent.torrent_id, torrent.filename, torrent.trackers, - torrent.options["compact_allocation"], + torrent.get_status(["storage_mode"])["storage_mode"], paused, torrent.options["download_location"], torrent.options["max_connections"], diff --git a/deluge/ui/console/modes/preference_panes.py b/deluge/ui/console/modes/preference_panes.py index 78c4efd39..315b1b6a6 100644 --- a/deluge/ui/console/modes/preference_panes.py +++ b/deluge/ui/console/modes/preference_panes.py @@ -231,12 +231,8 @@ class DownloadsPane(BasePane): self.add_checked_input("del_copy_torrent_file","Delete copy of torrent file on remove",parent.core_config["del_copy_torrent_file"]) self.add_header("Allocation",True) + self.add_checked_input("pre_allocate_storage", "Pre-Allocate disk space", parent.core_config["pre_allocate_storage"]) - if parent.core_config["compact_allocation"]: - alloc_idx = 1 - else: - alloc_idx = 0 - self.add_select_input("compact_allocation",None,["Use Full Allocation","Use Compact Allocation"],[False,True],alloc_idx) self.add_header("Options",True) self.add_checked_input("prioritize_first_last_pieces","Prioritize first and last pieces of torrent",parent.core_config["prioritize_first_last_pieces"]) self.add_checked_input("add_paused","Add torrents in paused state",parent.core_config["add_paused"]) diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index 38068fe0d..079a528e6 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -90,7 +90,7 @@ class AddTorrentDialog(component.Component): "on_button_add_clicked": self._on_button_add_clicked, "on_button_apply_clicked": self._on_button_apply_clicked, "on_button_revert_clicked": self._on_button_revert_clicked, - "on_alocation_toggled": self._on_alocation_toggled, + "on_allocation_toggled": self._on_allocation_toggled, "on_chk_move_completed_toggled": self._on_chk_move_completed_toggled }) @@ -151,7 +151,7 @@ class AddTorrentDialog(component.Component): # Get default config values from the core self.core_keys = [ - "compact_allocation", + "pre_allocate_storage", "max_connections_per_torrent", "max_upload_slots_per_torrent", "max_upload_speed_per_torrent", @@ -397,10 +397,8 @@ class AddTorrentDialog(component.Component): self.download_location_path_chooser.set_text(options["download_location"], cursor_end=True) self.move_completed_path_chooser.set_text(options["move_completed_path"], cursor_end=True) - self.builder.get_object("radio_full").set_active( - not options["compact_allocation"]) - self.builder.get_object("radio_compact").set_active( - options["compact_allocation"]) + #self.builder.get_object("radio_full").set_active( + #self.builder.get_object("radio_pre_alloc").set_active( self.builder.get_object("spin_maxdown").set_value( options["max_download_speed"]) self.builder.get_object("spin_maxup").set_value( @@ -411,6 +409,8 @@ class AddTorrentDialog(component.Component): options["max_upload_slots"]) self.builder.get_object("chk_paused").set_active( options["add_paused"]) + self.builder.get_object("chk_pre_alloc").set_active( + options["pre_allocate_storage"]) self.builder.get_object("chk_prioritize").set_active( options["prioritize_first_last_pieces"]) self.builder.get_object("chk_sequential_download").set_active( @@ -437,16 +437,8 @@ class AddTorrentDialog(component.Component): options["download_location"] = self.download_location_path_chooser.get_text() options["move_completed_path"] = self.move_completed_path_chooser.get_text() - options["compact_allocation"] = self.builder.get_object("radio_compact").get_active() + options["pre_allocate_storage"] = self.builder.get_object("chk_pre_alloc").get_active() options["move_completed"] = self.builder.get_object("chk_move_completed").get_active() - - if options["compact_allocation"]: - # We need to make sure all the files are set to download - def set_download_true(model, path, itr): - model[path][0] = True - self.files_treestore.foreach(set_download_true) - self.update_treeview_toggles(self.files_treestore.get_iter_first()) - options["max_download_speed"] = \ self.builder.get_object("spin_maxdown").get_value() options["max_upload_speed"] = \ @@ -490,10 +482,8 @@ class AddTorrentDialog(component.Component): def set_default_options(self): self.load_path_choosers_data() - self.builder.get_object("radio_compact").set_active( - self.core_config["compact_allocation"]) - self.builder.get_object("radio_full").set_active( - not self.core_config["compact_allocation"]) + self.builder.get_object("chk_pre_alloc").set_active( + self.core_config["pre_allocate_storage"]) self.builder.get_object("spin_maxdown").set_value( self.core_config["max_download_speed_per_torrent"]) self.builder.get_object("spin_maxup").set_value( @@ -524,23 +514,6 @@ class AddTorrentDialog(component.Component): return files_list def _on_file_toggled(self, render, path): - # Check to see if we can change file priorities - (model, row) = self.listview_torrents.get_selection().get_selected() - if self.options[model[row][0]]["compact_allocation"]: - def on_answer(response): - if response == gtk.RESPONSE_YES: - self.options[model[row][0]]["compact_allocation"] = False - self.update_torrent_options(model[row][0]) - - d = dialogs.YesNoDialog( - _("Unable to set file priority!"), - _("File prioritization is unavailable when using Compact " - "allocation. Would you like to switch to Full allocation?"), - self.dialog - ).run() - d.addCallback(on_answer) - - return (model, paths) = self.listview_files.get_selection().get_selected_rows() if len(paths) > 1: for path in paths: @@ -962,7 +935,7 @@ class AddTorrentDialog(component.Component): # to the 'mapped_files' option walk_tree(itr) - def _on_alocation_toggled(self, widget): + def _on_allocation_toggled(self, widget): full_allocation_active = self.builder.get_object("radio_full").get_active() self.builder.get_object("chk_prioritize").set_sensitive(full_allocation_active) self.builder.get_object("chk_sequential_download").set_sensitive(full_allocation_active) diff --git a/deluge/ui/gtkui/files_tab.py b/deluge/ui/gtkui/files_tab.py index 10dbd4ad7..5c051a6ec 100644 --- a/deluge/ui/gtkui/files_tab.py +++ b/deluge/ui/gtkui/files_tab.py @@ -301,7 +301,7 @@ class FilesTab(Tab): # We only want to do this if the torrent_id has changed self.treestore.clear() self.torrent_id = torrent_id - status_keys += ["compact", "is_seed"] + status_keys += ["storage_mode", "is_seed"] if self.torrent_id in self.files_list: # We already have the files list stored, so just update the view @@ -448,8 +448,8 @@ class FilesTab(Tab): return # Store this torrent's compact setting - if "compact" in status: - self.__compact = status["compact"] + if status["storage_mode"] == "compact": + self.__compact = True if "is_seed" in status: self.__is_seed = status["is_seed"] diff --git a/deluge/ui/gtkui/glade/add_torrent_dialog.ui b/deluge/ui/gtkui/glade/add_torrent_dialog.ui index 4a4b101bb..f3000f3b6 100644 --- a/deluge/ui/gtkui/glade/add_torrent_dialog.ui +++ b/deluge/ui/gtkui/glade/add_torrent_dialog.ui @@ -464,75 +464,6 @@ True False 10 - - - True - False - 0 - none - - - True - False - 5 - 12 - - - True - False - - - Full - True - True - False - True - True - - - - False - False - 0 - - - - - Compact - True - True - False - True - radio_full - - - - False - False - 1 - - - - - - - - - True - False - Allocation - - - - - - - - False - False - 0 - - True @@ -772,6 +703,21 @@ used sparingly. 2 + + + Pre-allocate disk space + True + True + False + Pre-allocate the disk space for the torrent files + True + + + False + False + 3 + + diff --git a/deluge/ui/gtkui/glade/preferences_dialog.ui b/deluge/ui/gtkui/glade/preferences_dialog.ui index 86b8cc8ba..5c5f48d9b 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.ui +++ b/deluge/ui/gtkui/glade/preferences_dialog.ui @@ -1436,80 +1436,6 @@ status tab (<b>EXPERIMENTAL!!!</b>) 2 - - - True - False - 0 - none - - - True - False - 2 - 2 - 12 - - - True - False - 10 - - - Use Full Allocation - True - True - False - Full allocation preallocates all of the space that is needed for the torrent and prevents disk fragmentation - True - True - - - - False - False - 0 - - - - - Use Compact Allocation - True - True - False - Compact allocation only allocates space as needed - True - radio_full_allocation - - - - False - False - 1 - - - - - - - - - True - False - Allocation - - - - - - - - False - False - 5 - 3 - - True @@ -1576,6 +1502,21 @@ used sparingly. 2 + + + Pre-allocate disk space + True + True + False + Pre-allocate the disk space for the torrent files + True + + + True + True + 3 + + diff --git a/deluge/ui/gtkui/options_tab.py b/deluge/ui/gtkui/options_tab.py index 39bf15831..e74aacca5 100644 --- a/deluge/ui/gtkui/options_tab.py +++ b/deluge/ui/gtkui/options_tab.py @@ -124,7 +124,7 @@ class OptionsTab(Tab): "stop_at_ratio", "stop_ratio", "remove_at_ratio", - "compact", + "storage_mode", "sequential_download", "move_on_completed", "move_on_completed_path", @@ -172,7 +172,7 @@ class OptionsTab(Tab): if status["shared"] != self.prev_status["shared"]: self.chk_shared.set_active(status["shared"]) - if status["compact"]: + if status["storage_mode"] == "compact": self.chk_prioritize_first_last.set_sensitive(False) if self.chk_sequential_download.get_property("visible"): self.chk_prioritize_first_last.hide() @@ -214,13 +214,13 @@ class OptionsTab(Tab): ) if self.chk_prioritize_first_last.get_active() != \ self.prev_status["prioritize_first_last"] and \ - not self.prev_status["compact"]: + not self.prev_status["storage_mode"] == "compact": client.core.set_torrent_prioritize_first_last( self.prev_torrent_id, self.chk_prioritize_first_last.get_active() ) if self.chk_sequential_download.get_active() != \ self.prev_status["sequential_download"] and \ - not self.prev_status["compact"]: + not self.prev_status["storage_mode"] == "compact": client.core.set_torrent_sequential_download( self.prev_torrent_id, self.chk_prioritize_first_last.get_active() ) diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 7ac653114..e497b5c0a 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -170,7 +170,7 @@ class Preferences(component.Component): "on_accounts_add_clicked": self._on_accounts_add_clicked, "on_accounts_delete_clicked": self._on_accounts_delete_clicked, "on_accounts_edit_clicked": self._on_accounts_edit_clicked, - "on_alocation_toggled": self._on_alocation_toggled, + "on_allocation_toggled": self._on_allocation_toggled, "on_piecesbar_toggle_toggled": self._on_piecesbar_toggle_toggled, "on_completed_color_set": self._on_completed_color_set, "on_revert_color_completed_clicked": self._on_revert_color_completed_clicked, @@ -354,8 +354,7 @@ class Preferences(component.Component): "chk_move_completed": ("active", "move_completed"), "chk_copy_torrent_file": ("active", "copy_torrent_file"), "chk_del_copy_torrent_file": ("active", "del_copy_torrent_file"), - "radio_compact_allocation": ("active", "compact_allocation"), - "radio_full_allocation": ("not_active", "compact_allocation"), + "chk_pre_allocation": ("active", "pre_allocate_storage"), "chk_prioritize_first_last_pieces": ("active", "prioritize_first_last_pieces"), "chk_sequential_download": ("active", "sequential_download"), "chk_add_paused": ("active", "add_paused"), @@ -582,19 +581,12 @@ class Preferences(component.Component): new_core_config["download_location"] = self.download_location_path_chooser.get_text() new_core_config["move_completed_path"] = self.move_completed_path_chooser.get_text() new_core_config["torrentfiles_location"] = self.copy_torrent_files_path_chooser.get_text() - - new_core_config["compact_allocation"] = \ - self.builder.get_object("radio_compact_allocation").get_active() new_core_config["prioritize_first_last_pieces"] = \ - self.builder.get_object( - "chk_prioritize_first_last_pieces").get_active() + self.builder.get_object("chk_prioritize_first_last_pieces").get_active() new_core_config["sequential_download"] = \ self.builder.get_object("chk_sequential_download").get_active() - new_core_config["sequential_download"] = \ - self.builder.get_object("radio_compact_allocation").get_active() and \ - False or self.builder.get_object("chk_sequential_download").get_active() - new_core_config["add_paused"] = \ - self.builder.get_object("chk_add_paused").get_active() + new_core_config["add_paused"] = self.builder.get_object("chk_add_paused").get_active() + new_core_config["pre_allocate_storage"] = self.builder.get_object("chk_pre_allocation").get_active() ## Network tab ## listen_ports = ( @@ -1253,7 +1245,7 @@ class Preferences(component.Component): ).addCallback(remove_ok).addErrback(remove_fail) dialog.run().addCallback(dialog_finished) - def _on_alocation_toggled(self, widget): + def _on_allocation_toggled(self, widget): full_allocation_active = self.builder.get_object("radio_full_allocation").get_active() self.builder.get_object("chk_prioritize_first_last_pieces").set_sensitive(full_allocation_active) self.builder.get_object("chk_sequential_download").set_sensitive(full_allocation_active) diff --git a/deluge/ui/web/js/deluge-all/add/OptionsPanel.js b/deluge/ui/web/js/deluge-all/add/OptionsPanel.js index 466b0a0f0..d64408d39 100644 --- a/deluge/ui/web/js/deluge-all/add/OptionsPanel.js +++ b/deluge/ui/web/js/deluge-all/add/OptionsPanel.js @@ -137,34 +137,12 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { }, onFilesChecked: function(nodes, newValue, oldValue) { - if (this.form.optionsManager.get('compact_allocation')) { - Ext.Msg.show({ - title: _('Unable to set file priority!'), - msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'), - buttons: Ext.Msg.YESNO, - fn: function(result) { - if (result == 'yes') { - this.form.optionsManager.update('compact_allocation', false); - Ext.each(nodes, function(node) { - if (node.attributes.fileindex < 0) return; - var priorities = this.form.optionsManager.get('file_priorities'); - priorities[node.attributes.fileindex] = newValue; - this.form.optionsManager.update('file_priorities', priorities); - }, this); - } else { - this.files.setDownload(nodes[0], oldValue, true); - } - }, - scope: this, - icon: Ext.MessageBox.QUESTION - }); - } else { - Ext.each(nodes, function(node) { - if (node.attributes.fileindex < 0) return; - var priorities = this.form.optionsManager.get('file_priorities'); - priorities[node.attributes.fileindex] = newValue; - this.form.optionsManager.update('file_priorities', priorities); - }, this); - } + Ext.each(nodes, function(node) { + if (node.attributes.fileindex < 0) return; + var priorities = this.form.optionsManager.get('file_priorities'); + priorities[node.attributes.fileindex] = newValue; + this.form.optionsManager.update('file_priorities', priorities); + }, this); + } }); diff --git a/deluge/ui/web/js/deluge-all/add/OptionsTab.js b/deluge/ui/web/js/deluge-all/add/OptionsTab.js index 04ee39fac..6e226ffe3 100644 --- a/deluge/ui/web/js/deluge-all/add/OptionsTab.js +++ b/deluge/ui/web/js/deluge-all/add/OptionsTab.js @@ -89,35 +89,6 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, { layout: 'column', defaultType: 'fieldset' }); - fieldset = panel.add({ - title: _('Allocation'), - border: false, - autoHeight: true, - defaultType: 'radio' - }); - - this.optionsManager.bind('compact_allocation', fieldset.add({ - xtype: 'radiogroup', - columns: 1, - vertical: true, - labelSeparator: '', - width: 80, - items: [{ - name: 'compact_allocation', - value: false, - inputValue: false, - boxLabel: _('Full'), - fieldLabel: '', - labelSeparator: '' - }, { - name: 'compact_allocation', - value: true, - inputValue: true, - boxLabel: _('Compact'), - fieldLabel: '', - labelSeparator: '' - }] - })); fieldset = panel.add({ title: _('Bandwidth'), @@ -167,10 +138,16 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, { fieldLabel: '', labelSeparator: '' })); + this.optionsManager.bind('pre_allocate_storage', fieldset.add({ + name: 'pre_allocate_storage', + boxLabel: _('Pre-allocate disk space'), + fieldLabel: '', + labelSeparator: '' + })); }, getDefaults: function() { - var keys = ['add_paused','compact_allocation','download_location', + var keys = ['add_paused','pre_allocate_storage','download_location', 'max_connections_per_torrent','max_download_speed_per_torrent', 'move_completed', 'move_completed_path', 'max_upload_slots_per_torrent','max_upload_speed_per_torrent', @@ -181,7 +158,7 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, { var options = { 'file_priorities': [], 'add_paused': config.add_paused, - 'compact_allocation': config.compact_allocation, + 'pre_allocate_storage': config.pre_allocate_storage, 'download_location': config.download_location, 'move_completed': config.move_completed, 'move_completed_path': config.move_completed_path, diff --git a/deluge/ui/web/js/deluge-all/preferences/DownloadsPage.js b/deluge/ui/web/js/deluge-all/preferences/DownloadsPage.js index 6984db040..0d053ceb0 100644 --- a/deluge/ui/web/js/deluge-all/preferences/DownloadsPage.js +++ b/deluge/ui/web/js/deluge-all/preferences/DownloadsPage.js @@ -1,6 +1,6 @@ /*! * Deluge.preferences.DownloadsPage.js - * + * * Copyright (c) Damien Churchill 2009-2010 * * This program is free software; you can redistribute it and/or modify @@ -93,36 +93,7 @@ Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, { }); optMan.bind('autoadd_enable', field.toggle); optMan.bind('autoadd_location', field.input); - - fieldset = this.add({ - xtype: 'fieldset', - border: false, - title: _('Allocation'), - autoHeight: true, - labelWidth: 1, - defaultType: 'radiogroup', - style: 'margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;', - width: 240 - }); - optMan.bind('compact_allocation', fieldset.add({ - name: 'compact_allocation', - width: 200, - labelSeparator: '', - //disabled: true, - defaults: { - width: 80, - height: 22, - name: 'compact_allocation' - }, - items: [{ - boxLabel: _('Use Full'), - inputValue: false - }, { - boxLabel: _('Use Compact'), - inputValue: true - }] - })); - + fieldset = this.add({ xtype: 'fieldset', border: false, @@ -145,5 +116,12 @@ Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, { height: 22, boxLabel: _('Add torrents in Paused state') })); + optMan.bind('pre_allocate_storage', fieldset.add({ + name: 'pre_allocate_storage', + labelSeparator: '', + height: 22, + boxLabel: _('Pre-allocate disk space') + })); + } });