[#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'.
This commit is contained in:
Calum Lind 2014-02-16 00:37:45 +00:00
parent 4486592f04
commit 67e9787ba1
13 changed files with 110 additions and 319 deletions

View File

@ -53,7 +53,7 @@ DEFAULT_PREFS = {
"info_sent": 0.0, "info_sent": 0.0,
"daemon_port": 58846, "daemon_port": 58846,
"allow_remote": False, "allow_remote": False,
"compact_allocation": False, "pre_allocate_storage": False,
"download_location": deluge.common.get_default_download_dir(), "download_location": deluge.common.get_default_download_dir(),
"listen_ports": [6881, 6891], "listen_ports": [6881, 6891],
"listen_interface": "", "listen_interface": "",

View File

@ -69,8 +69,7 @@ class TorrentOptions(dict):
limit you set.The default is unlimited (-1) but will not exceed global limit. 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. 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. sequential_download (bool): Download the pieces of the torrent in order.
compact_allocation (bool): Use compact allocation instead of full allocation pre_allocate_storage (bool): When adding the torrent should all files be pre-allocated.
for this torrent's data.
download_location (str): The path for the torrent data to be stored while downloading. 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. 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. 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", "max_download_speed": "max_download_speed_per_torrent",
"prioritize_first_last_pieces": "prioritize_first_last_pieces", "prioritize_first_last_pieces": "prioritize_first_last_pieces",
"sequential_download": "sequential_download", "sequential_download": "sequential_download",
"compact_allocation": "compact_allocation", "pre_allocate_storage": "pre_allocate_storage",
"download_location": "download_location", "download_location": "download_location",
"auto_managed": "auto_managed", "auto_managed": "auto_managed",
"stop_at_ratio": "stop_seed_at_ratio", "stop_at_ratio": "stop_seed_at_ratio",
@ -313,7 +312,7 @@ class Torrent(object):
return return
if not self.has_metadata: if not self.has_metadata:
return 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!") log.debug("Setting first/last priority with compact allocation does not work!")
return return
# A list of priorities for each piece in the torrent # A list of priorities for each piece in the torrent
@ -348,8 +347,11 @@ class Torrent(object):
Args: Args:
set_sequencial (bool): Enable sequencial downloading. set_sequencial (bool): Enable sequencial downloading.
""" """
self.options["sequential_download"] = set_sequencial if self.get_status(["storage_mode"])["storage_mode"] != "compact":
self.handle.set_sequential_download(set_sequencial) 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): def set_auto_managed(self, auto_managed):
"""Set auto managed mode, i.e. will be started or queued automatically. """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() self.options["file_priorities"] = self.handle.file_priorities()
return 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!") log.warning("Setting file priority with compact allocation does not work!")
self.options["file_priorities"] = self.handle.file_priorities() self.options["file_priorities"] = self.handle.file_priorities()
return return
@ -853,7 +855,7 @@ class Torrent(object):
self.status_funcs = { self.status_funcs = {
"active_time": lambda: self.status.active_time, "active_time": lambda: self.status.active_time,
"all_time_download": lambda: self.status.all_time_download, "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 "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 self.status.distributed_copies, # Adjust status.distributed_copies to return a non-negative value
"download_payload_rate": lambda: self.status.download_payload_rate, "download_payload_rate": lambda: self.status.download_payload_rate,

View File

@ -67,7 +67,7 @@ class TorrentState:
torrent_id=None, torrent_id=None,
filename=None, filename=None,
trackers=None, trackers=None,
compact=False, storage_mode="sparse",
paused=False, paused=False,
save_path=None, save_path=None,
max_connections=-1, max_connections=-1,
@ -100,7 +100,7 @@ class TorrentState:
self.magnet = magnet self.magnet = magnet
# Options # Options
self.compact = compact self.storage_mode = storage_mode
self.paused = paused self.paused = paused
self.save_path = save_path self.save_path = save_path
self.max_connections = max_connections self.max_connections = max_connections
@ -347,7 +347,8 @@ class TorrentManager(component.Component):
options["prioritize_first_last_pieces"] = state.prioritize_first_last options["prioritize_first_last_pieces"] = state.prioritize_first_last
options["sequential_download"] = state.sequential_download options["sequential_download"] = state.sequential_download
options["file_priorities"] = state.file_priorities 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["download_location"] = state.save_path
options["auto_managed"] = state.auto_managed options["auto_managed"] = state.auto_managed
options["stop_at_ratio"] = state.stop_at_ratio options["stop_at_ratio"] = state.stop_at_ratio
@ -362,6 +363,7 @@ class TorrentManager(component.Component):
options["owner"] = state.owner options["owner"] = state.owner
options["name"] = state.name options["name"] = state.name
torrent_info = self.get_torrent_info_from_file( torrent_info = self.get_torrent_info_from_file(
os.path.join(self.state_dir, state.torrent_id + ".torrent")) os.path.join(self.state_dir, state.torrent_id + ".torrent"))
if torrent_info: if torrent_info:
@ -427,6 +429,11 @@ class TorrentManager(component.Component):
except TypeError: except TypeError:
torrent_info.rename_file(index, fname.encode("utf-8")) 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 add_torrent_params["ti"] = torrent_info
if log.isEnabledFor(logging.DEBUG): if log.isEnabledFor(logging.DEBUG):
@ -438,15 +445,13 @@ class TorrentManager(component.Component):
if not account_exists: if not account_exists:
options["owner"] = "localclient" 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 # Fill in the rest of the add_torrent_params dictionary
add_torrent_params["save_path"] = utf8_encoded(options["download_location"]) 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 | default_flags = (lt.add_torrent_params_flags_t.flag_paused |
lt.add_torrent_params_flags_t.flag_auto_managed | lt.add_torrent_params_flags_t.flag_auto_managed |
@ -643,14 +648,17 @@ class TorrentManager(component.Component):
if state is None: if state is None:
state = TorrentManagerState() 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: try:
if len(state.torrents) > 0: if len(state.torrents) > 0:
state_tmp = TorrentState() state_tmp = TorrentState()
if dir(state.torrents[0]) != dir(state_tmp): if dir(state.torrents[0]) != dir(state_tmp):
for attr in (set(dir(state_tmp)) - set(dir(state.torrents[0]))): for attr in (set(dir(state_tmp)) - set(dir(state.torrents[0]))):
for s in state.torrents: 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: except Exception, e:
log.exception("Unable to update state file to a compatible version: %s", 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.torrent_id,
torrent.filename, torrent.filename,
torrent.trackers, torrent.trackers,
torrent.options["compact_allocation"], torrent.get_status(["storage_mode"])["storage_mode"],
paused, paused,
torrent.options["download_location"], torrent.options["download_location"],
torrent.options["max_connections"], torrent.options["max_connections"],

View File

@ -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_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_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_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("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"]) self.add_checked_input("add_paused","Add torrents in paused state",parent.core_config["add_paused"])

View File

@ -90,7 +90,7 @@ class AddTorrentDialog(component.Component):
"on_button_add_clicked": self._on_button_add_clicked, "on_button_add_clicked": self._on_button_add_clicked,
"on_button_apply_clicked": self._on_button_apply_clicked, "on_button_apply_clicked": self._on_button_apply_clicked,
"on_button_revert_clicked": self._on_button_revert_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 "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 # Get default config values from the core
self.core_keys = [ self.core_keys = [
"compact_allocation", "pre_allocate_storage",
"max_connections_per_torrent", "max_connections_per_torrent",
"max_upload_slots_per_torrent", "max_upload_slots_per_torrent",
"max_upload_speed_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.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.move_completed_path_chooser.set_text(options["move_completed_path"], cursor_end=True)
self.builder.get_object("radio_full").set_active( #self.builder.get_object("radio_full").set_active(
not options["compact_allocation"]) #self.builder.get_object("radio_pre_alloc").set_active(
self.builder.get_object("radio_compact").set_active(
options["compact_allocation"])
self.builder.get_object("spin_maxdown").set_value( self.builder.get_object("spin_maxdown").set_value(
options["max_download_speed"]) options["max_download_speed"])
self.builder.get_object("spin_maxup").set_value( self.builder.get_object("spin_maxup").set_value(
@ -411,6 +409,8 @@ class AddTorrentDialog(component.Component):
options["max_upload_slots"]) options["max_upload_slots"])
self.builder.get_object("chk_paused").set_active( self.builder.get_object("chk_paused").set_active(
options["add_paused"]) options["add_paused"])
self.builder.get_object("chk_pre_alloc").set_active(
options["pre_allocate_storage"])
self.builder.get_object("chk_prioritize").set_active( self.builder.get_object("chk_prioritize").set_active(
options["prioritize_first_last_pieces"]) options["prioritize_first_last_pieces"])
self.builder.get_object("chk_sequential_download").set_active( 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["download_location"] = self.download_location_path_chooser.get_text()
options["move_completed_path"] = self.move_completed_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() 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"] = \ options["max_download_speed"] = \
self.builder.get_object("spin_maxdown").get_value() self.builder.get_object("spin_maxdown").get_value()
options["max_upload_speed"] = \ options["max_upload_speed"] = \
@ -490,10 +482,8 @@ class AddTorrentDialog(component.Component):
def set_default_options(self): def set_default_options(self):
self.load_path_choosers_data() self.load_path_choosers_data()
self.builder.get_object("radio_compact").set_active( self.builder.get_object("chk_pre_alloc").set_active(
self.core_config["compact_allocation"]) self.core_config["pre_allocate_storage"])
self.builder.get_object("radio_full").set_active(
not self.core_config["compact_allocation"])
self.builder.get_object("spin_maxdown").set_value( self.builder.get_object("spin_maxdown").set_value(
self.core_config["max_download_speed_per_torrent"]) self.core_config["max_download_speed_per_torrent"])
self.builder.get_object("spin_maxup").set_value( self.builder.get_object("spin_maxup").set_value(
@ -524,23 +514,6 @@ class AddTorrentDialog(component.Component):
return files_list return files_list
def _on_file_toggled(self, render, path): 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() (model, paths) = self.listview_files.get_selection().get_selected_rows()
if len(paths) > 1: if len(paths) > 1:
for path in paths: for path in paths:
@ -962,7 +935,7 @@ class AddTorrentDialog(component.Component):
# to the 'mapped_files' option # to the 'mapped_files' option
walk_tree(itr) 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() 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_prioritize").set_sensitive(full_allocation_active)
self.builder.get_object("chk_sequential_download").set_sensitive(full_allocation_active) self.builder.get_object("chk_sequential_download").set_sensitive(full_allocation_active)

View File

@ -301,7 +301,7 @@ class FilesTab(Tab):
# We only want to do this if the torrent_id has changed # We only want to do this if the torrent_id has changed
self.treestore.clear() self.treestore.clear()
self.torrent_id = torrent_id self.torrent_id = torrent_id
status_keys += ["compact", "is_seed"] status_keys += ["storage_mode", "is_seed"]
if self.torrent_id in self.files_list: if self.torrent_id in self.files_list:
# We already have the files list stored, so just update the view # We already have the files list stored, so just update the view
@ -448,8 +448,8 @@ class FilesTab(Tab):
return return
# Store this torrent's compact setting # Store this torrent's compact setting
if "compact" in status: if status["storage_mode"] == "compact":
self.__compact = status["compact"] self.__compact = True
if "is_seed" in status: if "is_seed" in status:
self.__is_seed = status["is_seed"] self.__is_seed = status["is_seed"]

View File

@ -464,75 +464,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="spacing">10</property> <property name="spacing">10</property>
<child>
<object class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">5</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkRadioButton" id="radio_full">
<property name="label" translatable="yes">Full</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_alocation_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_compact">
<property name="label" translatable="yes">Compact</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">radio_full</property>
<signal name="toggled" handler="on_alocation_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Allocation</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkFrame" id="frame5"> <object class="GtkFrame" id="frame5">
<property name="visible">True</property> <property name="visible">True</property>
@ -772,6 +703,21 @@ used sparingly.</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="chk_pre_alloc">
<property name="label" translatable="yes">Pre-allocate disk space</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Pre-allocate the disk space for the torrent files</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>

View File

@ -1436,80 +1436,6 @@ status tab (&lt;b&gt;EXPERIMENTAL!!!&lt;/b&gt;)</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkFrame" id="frame6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">2</property>
<property name="bottom_padding">2</property>
<property name="left_padding">12</property>
<child>
<object class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">10</property>
<child>
<object class="GtkRadioButton" id="radio_full_allocation">
<property name="label" translatable="yes">Use Full Allocation</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Full allocation preallocates all of the space that is needed for the torrent and prevents disk fragmentation</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_alocation_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_compact_allocation">
<property name="label" translatable="yes">Use Compact Allocation</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Compact allocation only allocates space as needed</property>
<property name="draw_indicator">True</property>
<property name="group">radio_full_allocation</property>
<signal name="toggled" handler="on_alocation_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Allocation</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">3</property>
</packing>
</child>
<child> <child>
<object class="GtkFrame" id="frame7"> <object class="GtkFrame" id="frame7">
<property name="visible">True</property> <property name="visible">True</property>
@ -1576,6 +1502,21 @@ used sparingly.</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="chk_pre_allocation">
<property name="label" translatable="yes">Pre-allocate disk space</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Pre-allocate the disk space for the torrent files</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>

View File

@ -124,7 +124,7 @@ class OptionsTab(Tab):
"stop_at_ratio", "stop_at_ratio",
"stop_ratio", "stop_ratio",
"remove_at_ratio", "remove_at_ratio",
"compact", "storage_mode",
"sequential_download", "sequential_download",
"move_on_completed", "move_on_completed",
"move_on_completed_path", "move_on_completed_path",
@ -172,7 +172,7 @@ class OptionsTab(Tab):
if status["shared"] != self.prev_status["shared"]: if status["shared"] != self.prev_status["shared"]:
self.chk_shared.set_active(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) self.chk_prioritize_first_last.set_sensitive(False)
if self.chk_sequential_download.get_property("visible"): if self.chk_sequential_download.get_property("visible"):
self.chk_prioritize_first_last.hide() self.chk_prioritize_first_last.hide()
@ -214,13 +214,13 @@ class OptionsTab(Tab):
) )
if self.chk_prioritize_first_last.get_active() != \ if self.chk_prioritize_first_last.get_active() != \
self.prev_status["prioritize_first_last"] and \ 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( client.core.set_torrent_prioritize_first_last(
self.prev_torrent_id, self.chk_prioritize_first_last.get_active() self.prev_torrent_id, self.chk_prioritize_first_last.get_active()
) )
if self.chk_sequential_download.get_active() != \ if self.chk_sequential_download.get_active() != \
self.prev_status["sequential_download"] and \ self.prev_status["sequential_download"] and \
not self.prev_status["compact"]: not self.prev_status["storage_mode"] == "compact":
client.core.set_torrent_sequential_download( client.core.set_torrent_sequential_download(
self.prev_torrent_id, self.chk_prioritize_first_last.get_active() self.prev_torrent_id, self.chk_prioritize_first_last.get_active()
) )

View File

@ -170,7 +170,7 @@ class Preferences(component.Component):
"on_accounts_add_clicked": self._on_accounts_add_clicked, "on_accounts_add_clicked": self._on_accounts_add_clicked,
"on_accounts_delete_clicked": self._on_accounts_delete_clicked, "on_accounts_delete_clicked": self._on_accounts_delete_clicked,
"on_accounts_edit_clicked": self._on_accounts_edit_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_piecesbar_toggle_toggled": self._on_piecesbar_toggle_toggled,
"on_completed_color_set": self._on_completed_color_set, "on_completed_color_set": self._on_completed_color_set,
"on_revert_color_completed_clicked": self._on_revert_color_completed_clicked, "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_move_completed": ("active", "move_completed"),
"chk_copy_torrent_file": ("active", "copy_torrent_file"), "chk_copy_torrent_file": ("active", "copy_torrent_file"),
"chk_del_copy_torrent_file": ("active", "del_copy_torrent_file"), "chk_del_copy_torrent_file": ("active", "del_copy_torrent_file"),
"radio_compact_allocation": ("active", "compact_allocation"), "chk_pre_allocation": ("active", "pre_allocate_storage"),
"radio_full_allocation": ("not_active", "compact_allocation"),
"chk_prioritize_first_last_pieces": ("active", "prioritize_first_last_pieces"), "chk_prioritize_first_last_pieces": ("active", "prioritize_first_last_pieces"),
"chk_sequential_download": ("active", "sequential_download"), "chk_sequential_download": ("active", "sequential_download"),
"chk_add_paused": ("active", "add_paused"), "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["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["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["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"] = \ new_core_config["prioritize_first_last_pieces"] = \
self.builder.get_object( self.builder.get_object("chk_prioritize_first_last_pieces").get_active()
"chk_prioritize_first_last_pieces").get_active()
new_core_config["sequential_download"] = \ new_core_config["sequential_download"] = \
self.builder.get_object("chk_sequential_download").get_active() self.builder.get_object("chk_sequential_download").get_active()
new_core_config["sequential_download"] = \ new_core_config["add_paused"] = self.builder.get_object("chk_add_paused").get_active()
self.builder.get_object("radio_compact_allocation").get_active() and \ new_core_config["pre_allocate_storage"] = self.builder.get_object("chk_pre_allocation").get_active()
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()
## Network tab ## ## Network tab ##
listen_ports = ( listen_ports = (
@ -1253,7 +1245,7 @@ class Preferences(component.Component):
).addCallback(remove_ok).addErrback(remove_fail) ).addCallback(remove_ok).addErrback(remove_fail)
dialog.run().addCallback(dialog_finished) 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() 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_prioritize_first_last_pieces").set_sensitive(full_allocation_active)
self.builder.get_object("chk_sequential_download").set_sensitive(full_allocation_active) self.builder.get_object("chk_sequential_download").set_sensitive(full_allocation_active)

View File

@ -137,34 +137,12 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
}, },
onFilesChecked: function(nodes, newValue, oldValue) { onFilesChecked: function(nodes, newValue, oldValue) {
if (this.form.optionsManager.get('compact_allocation')) { Ext.each(nodes, function(node) {
Ext.Msg.show({ if (node.attributes.fileindex < 0) return;
title: _('Unable to set file priority!'), var priorities = this.form.optionsManager.get('file_priorities');
msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'), priorities[node.attributes.fileindex] = newValue;
buttons: Ext.Msg.YESNO, this.form.optionsManager.update('file_priorities', priorities);
fn: function(result) { }, this);
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);
}
} }
}); });

View File

@ -89,35 +89,6 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
layout: 'column', layout: 'column',
defaultType: 'fieldset' 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({ fieldset = panel.add({
title: _('Bandwidth'), title: _('Bandwidth'),
@ -167,10 +138,16 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
fieldLabel: '', fieldLabel: '',
labelSeparator: '' labelSeparator: ''
})); }));
this.optionsManager.bind('pre_allocate_storage', fieldset.add({
name: 'pre_allocate_storage',
boxLabel: _('Pre-allocate disk space'),
fieldLabel: '',
labelSeparator: ''
}));
}, },
getDefaults: function() { 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', 'max_connections_per_torrent','max_download_speed_per_torrent',
'move_completed', 'move_completed_path', 'move_completed', 'move_completed_path',
'max_upload_slots_per_torrent','max_upload_speed_per_torrent', 'max_upload_slots_per_torrent','max_upload_speed_per_torrent',
@ -181,7 +158,7 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
var options = { var options = {
'file_priorities': [], 'file_priorities': [],
'add_paused': config.add_paused, 'add_paused': config.add_paused,
'compact_allocation': config.compact_allocation, 'pre_allocate_storage': config.pre_allocate_storage,
'download_location': config.download_location, 'download_location': config.download_location,
'move_completed': config.move_completed, 'move_completed': config.move_completed,
'move_completed_path': config.move_completed_path, 'move_completed_path': config.move_completed_path,

View File

@ -1,6 +1,6 @@
/*! /*!
* Deluge.preferences.DownloadsPage.js * Deluge.preferences.DownloadsPage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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_enable', field.toggle);
optMan.bind('autoadd_location', field.input); 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({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
@ -145,5 +116,12 @@ Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
height: 22, height: 22,
boxLabel: _('Add torrents in Paused state') 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')
}));
} }
}); });