diff --git a/deluge/core/core.py b/deluge/core/core.py index b8c39bdb7..8968ba488 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -218,18 +218,15 @@ class Core(component.Component): # Exported Methods @export def add_torrent_file(self, filename, filedump, options): - """ - Adds a torrent file to the session. + """Adds a torrent file to the session. - :param filename: the filename of the torrent - :type filename: string - :param filedump: a base64 encoded string of the torrent file contents - :type filedump: string - :param options: the options to apply to the torrent on add - :type options: dict + Args: + filename (str): the filename of the torrent + filedump (str): A base64 encoded string of the torrent file contents + options (dict): The options to apply to the torrent on add - :returns: the torrent_id as a str or None - :rtype: string + Returns: + str: The torrent_id or None """ try: @@ -867,11 +864,11 @@ class Core(component.Component): def on_get_page(result): return bool(int(result)) - def logError(failure): + def on_error(failure): log.warning("Error testing listen port: %s", failure) d.addCallback(on_get_page) - d.addErrback(logError) + d.addErrback(on_error) return d diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 45147c2d5..a68bc34d8 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -118,6 +118,7 @@ class TorrentOptions(dict): mapped_files (dict): A mapping of the renamed filenames in 'index:filename' pairs. owner (str): The user this torrent belongs to. name (str): The display name of the torrent. + seed_mode (bool): Assume that all files are present for this torrent (Only used when adding a torent). """ def __init__(self): super(TorrentOptions, self).__init__() @@ -148,6 +149,7 @@ class TorrentOptions(dict): self["mapped_files"] = {} self["owner"] = "" self["name"] = "" + self["seed_mode"] = False class Torrent(object): diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 90c4a97ca..31d4af5b3 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -288,7 +288,7 @@ class TorrentManager(component.Component): return torrent_info def add(self, torrent_info=None, state=None, options=None, save_state=True, - filedump=None, filename=None, magnet=None, resume_data=None, seed_mode=False): + filedump=None, filename=None, magnet=None, resume_data=None): """Adds a torrent to the torrent manager. Args: @@ -300,8 +300,6 @@ class TorrentManager(component.Component): filename (str, optional): The filename of the torrent file. magnet (str, optional): The magnet uri. resume_data (lt.entry, optional): libtorrent fast resume data. - seed_mode (bool, optional): If True will assume that all files are present. - for this torrent, defaults to False. Returns: str: The torrent_id of the added torrent. @@ -451,7 +449,7 @@ class TorrentManager(component.Component): add_torrent_params["flags"] = ((default_flags | lt.add_torrent_params_flags_t.flag_duplicate_is_error) ^ lt.add_torrent_params_flags_t.flag_auto_managed) - if seed_mode: + if options["seed_mode"]: add_torrent_params["flags"] |= lt.add_torrent_params_flags_t.flag_seed_mode if magnet: diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index 83722b38f..d5175deea 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -449,6 +449,7 @@ class AddTorrentDialog(component.Component): self.builder.get_object("chk_sequential_download").get_active() or False options["move_completed"] = \ self.builder.get_object("chk_move_completed").get_active() + options["seed_mode"] = self.builder.get_object("chk_seed_mode").get_active() self.options[torrent_id] = options @@ -491,6 +492,7 @@ class AddTorrentDialog(component.Component): self.core_config["sequential_download"]) self.builder.get_object("chk_move_completed").set_active( self.core_config["move_completed"]) + self.builder.get_object("chk_seed_mode").set_active(False) def get_file_priorities(self, torrent_id): # A list of priorities @@ -762,7 +764,8 @@ class AddTorrentDialog(component.Component): client.core.add_torrent_file( os.path.split(filename)[-1], base64.encodestring(self.infos[torrent_id]), - options) + options + ) row = self.torrent_liststore.iter_next(row) self.hide() diff --git a/deluge/ui/gtkui/glade/add_torrent_dialog.ui b/deluge/ui/gtkui/glade/add_torrent_dialog.ui index aa6e3af56..7c2878139 100644 --- a/deluge/ui/gtkui/glade/add_torrent_dialog.ui +++ b/deluge/ui/gtkui/glade/add_torrent_dialog.ui @@ -88,6 +88,7 @@ center + False True True True @@ -135,6 +136,7 @@ + False True True True @@ -182,6 +184,7 @@ + False True True True @@ -229,6 +232,7 @@ + False True True True @@ -423,6 +427,7 @@ False + False True True False @@ -464,6 +469,129 @@ True False 10 + + + True + False + 0 + none + + + True + False + 5 + 7 + 12 + + + True + False + + + Add In _Paused State + False + True + True + False + True + True + + + False + False + 0 + + + + + Prioritize First/Last Pieces + False + True + True + False + True + + + False + False + 1 + + + + + Sequential Download + False + True + True + False + True + When enabled, the piece picker will pick pieces in +sequence instead of rarest first. + +Enabling sequential download will affect the piece +distribution negatively in the swarm. It should be +used sparingly. + True + + + False + False + 2 + + + + + Skip File Hash Check + False + True + True + False + Useful if adding a complete torrent for seeding. + True + + + True + True + 3 + + + + + Preallocate Disk Space + False + True + True + False + Preallocate the disk space for the torrent files + True + + + False + False + 4 + + + + + + + + + True + False + General + + + + + + + + False + False + 0 + + True @@ -497,62 +625,66 @@ 1 2 - - + + True False + Maximum torrent download speed 0 - Max Down Speed: + Down Speed: GTK_FILL - + True False + Maximum torrent upload speed 0 - Max Up Speed: + Up Speed: 1 2 GTK_FILL - + True False + Maximum torrent connections 0 - Max Connections: + Connections: 2 3 GTK_FILL - + True False + Maximum torrent upload slots 0 - Max Upload Slots: + Upload Slots: 3 4 GTK_FILL - + @@ -572,8 +704,8 @@ 2 1 2 - - + + @@ -592,8 +724,8 @@ 2 2 3 - - + + @@ -612,8 +744,8 @@ 2 3 4 - - + + @@ -637,108 +769,6 @@ 1 - - - True - False - 0 - none - - - True - False - 5 - 12 - - - True - False - - - Prioritize First/Last Pieces - True - True - False - True - - - False - False - 0 - - - - - Sequential Download - True - True - False - True - When enabled, the piece picker will pick pieces in -sequence instead of rarest first. - -Enabling sequential download will affect the piece -distribution negatively in the swarm. It should be -used sparingly. - True - - - False - False - 1 - - - - - Add In _Paused State - True - True - False - True - True - - - False - False - 2 - - - - - Pre-allocate disk space - True - True - False - Pre-allocate the disk space for the torrent files - True - - - False - False - 3 - - - - - - - - - True - False - General - - - - - - - - False - False - 2 - - False @@ -757,6 +787,7 @@ used sparingly. False + False True True True @@ -810,6 +841,7 @@ used sparingly. False + False True True True @@ -924,6 +956,7 @@ used sparingly. gtk-cancel + False True True True @@ -939,6 +972,7 @@ used sparingly. gtk-add + False True True True diff --git a/deluge/ui/web/js/deluge-all/add/OptionsTab.js b/deluge/ui/web/js/deluge-all/add/OptionsTab.js index a3fc04215..1846e2f7e 100644 --- a/deluge/ui/web/js/deluge-all/add/OptionsTab.js +++ b/deluge/ui/web/js/deluge-all/add/OptionsTab.js @@ -63,7 +63,7 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, { this.optionsManager.bind('download_location', fieldset.add({ fieldLabel: '', name: 'download_location', - width: 400, + anchor:'95%', labelSeparator: '' })); var fieldset = this.add({ @@ -79,7 +79,7 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, { var field = fieldset.add({ fieldLabel: '', name: 'move_completed_path', - width: 425 + anchor:'98%' }); this.optionsManager.bind('move_completed', field.toggle) this.optionsManager.bind('move_completed_path', field.input) @@ -126,6 +126,12 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, { autoHeight: true, defaultType: 'checkbox' }); + this.optionsManager.bind('add_paused', fieldset.add({ + name: 'add_paused', + boxLabel: _('Add In Paused State'), + fieldLabel: '', + labelSeparator: '' + })); this.optionsManager.bind('prioritize_first_last_pieces', fieldset.add({ name: 'prioritize_first_last_pieces', boxLabel: _('Prioritize First/Last Pieces'), @@ -134,19 +140,19 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, { })); this.optionsManager.bind('sequential_download', fieldset.add({ name: 'sequential_download', - boxLabel: _('Sequential download'), + boxLabel: _('Sequential Download'), fieldLabel: '', labelSeparator: '' })); - this.optionsManager.bind('add_paused', fieldset.add({ - name: 'add_paused', - boxLabel: _('Add In Paused State'), + this.optionsManager.bind('seed_mode', fieldset.add({ + name: 'seed_mode', + boxLabel: _('Skip File Hash Check'), fieldLabel: '', labelSeparator: '' })); this.optionsManager.bind('pre_allocate_storage', fieldset.add({ name: 'pre_allocate_storage', - boxLabel: _('Pre-allocate disk space'), + boxLabel: _('Preallocate Disk Space'), fieldLabel: '', labelSeparator: '' })); @@ -173,7 +179,8 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, { 'max_download_speed': config.max_download_speed_per_torrent, 'max_upload_slots': config.max_upload_slots_per_torrent, 'max_upload_speed': config.max_upload_speed_per_torrent, - 'prioritize_first_last_pieces': config.prioritize_first_last_pieces + 'prioritize_first_last_pieces': config.prioritize_first_last_pieces, + 'seed_mode': false } this.optionsManager.options = options; this.optionsManager.resetAll();