[#1294] [GTKUI] [WebUI] Add Skip File Hash Check

* Altered the core code so that seed_mode is now a torrent option.
 * Made some minor improvments to the Add Dialog
This commit is contained in:
Calum Lind 2014-08-10 00:05:28 +01:00
parent d108091511
commit 66ae8bdd5c
6 changed files with 184 additions and 143 deletions

View File

@ -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

View File

@ -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):

View File

@ -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:

View File

@ -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()

View File

@ -88,6 +88,7 @@
<property name="layout_style">center</property>
<child>
<object class="GtkButton" id="button_file">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -135,6 +136,7 @@
</child>
<child>
<object class="GtkButton" id="button_url">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -182,6 +184,7 @@
</child>
<child>
<object class="GtkButton" id="button_hash">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -229,6 +232,7 @@
</child>
<child>
<object class="GtkButton" id="button_remove">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -423,6 +427,7 @@
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="chk_move_completed">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@ -464,6 +469,129 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">10</property>
<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">5</property>
<property name="left_padding">7</property>
<property name="right_padding">12</property>
<child>
<object class="GtkVBox" id="vbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="chk_paused">
<property name="label" translatable="yes">Add In _Paused State</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chk_prioritize">
<property name="label" translatable="yes">Prioritize First/Last Pieces</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chk_sequential_download">
<property name="label" translatable="yes">Sequential Download</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_text" translatable="yes">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.</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chk_seed_mode">
<property name="label" translatable="yes">Skip File Hash Check</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_markup">Useful if adding a complete torrent for seeding.</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>
<child>
<object class="GtkCheckButton" id="chk_pre_alloc">
<property name="label" translatable="yes">Preallocate Disk Space</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Preallocate 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">4</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">General</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>
<object class="GtkFrame" id="frame5">
<property name="visible">True</property>
@ -497,62 +625,66 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options"/>
<property name="y_options"/>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Maximum torrent download speed</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Max Down Speed:</property>
<property name="label" translatable="yes">Down Speed:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Maximum torrent upload speed</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Max Up Speed:</property>
<property name="label" translatable="yes">Up Speed:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Maximum torrent connections</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Max Connections:</property>
<property name="label" translatable="yes">Connections:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Maximum torrent upload slots</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Max Upload Slots:</property>
<property name="label" translatable="yes">Upload Slots:</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="y_options"></property>
</packing>
</child>
<child>
@ -572,8 +704,8 @@
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"/>
<property name="y_options"/>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
@ -592,8 +724,8 @@
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options"/>
<property name="y_options"/>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
@ -612,8 +744,8 @@
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options"/>
<property name="y_options"/>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
</object>
@ -637,108 +769,6 @@
<property name="position">1</property>
</packing>
</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">5</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="chk_prioritize">
<property name="label" translatable="yes">Prioritize First/Last Pieces</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chk_sequential_download">
<property name="label" translatable="yes">Sequential Download</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_text" translatable="yes">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.</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chk_paused">
<property name="label" translatable="yes">Add In _Paused State</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</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>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">General</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">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -757,6 +787,7 @@ used sparingly.</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="button_apply">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -810,6 +841,7 @@ used sparingly.</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="button_revert">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -924,6 +956,7 @@ used sparingly.</property>
<child>
<object class="GtkButton" id="button_cancel">
<property name="label">gtk-cancel</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -939,6 +972,7 @@ used sparingly.</property>
<child>
<object class="GtkButton" id="button_add">
<property name="label">gtk-add</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>

View File

@ -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();