Implement #1063 option to delete torrent file copy on torrent removal - patch from Ghent

This commit is contained in:
Andrew Resch 2009-12-11 21:00:12 +00:00
parent 8212a66d5a
commit 62dfd6a664
5 changed files with 99 additions and 56 deletions

View File

@ -1,3 +1,7 @@
=== Deluge 1.3.0 (In Development) ===
==== Core ====
* Implement #1063 option to delete torrent file copy on torrent removal - patch from Ghent
=== Deluge 1.2.0 (In Development) ===
==== Core ====
* Implement new RPC protocol DelugeRPC replacing XMLRPC

View File

@ -58,6 +58,7 @@ DEFAULT_PREFS = {
"listen_ports": [6881, 6891],
"listen_interface": "",
"copy_torrent_file": False,
"del_copy_torrent_file": False,
"torrentfiles_location": deluge.common.get_default_download_dir(),
"plugins_location": os.path.join(deluge.configmanager.get_config_dir(), "plugins"),
"prioritize_first_last_pieces": False,

View File

@ -532,6 +532,21 @@ class TorrentManager(component.Component):
# Remove the .torrent file in the state
self.torrents[torrent_id].delete_torrentfile()
# Remove the torrent file from the user specified directory
filename = self.torrents[torrent_id].filename
if self.config["copy_torrent_file"] \
and self.config["del_copy_torrent_file"] \
and filename:
try:
users_torrent_file = os.path.join(
self.config["torrentfiles_location"],
filename)
log.info("Delete user's torrent file: %s",
users_torrent_file)
os.remove(users_torrent_file)
except Exception, e:
log.warning("Unable to remove copy torrent file: %s", e)
# Remove the torrent from deluge's session
try:
del self.torrents[torrent_id]

View File

@ -106,7 +106,7 @@
<child>
<widget class="GtkTable" id="table9">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_rows">5</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkAlignment" id="alignment11">
@ -139,45 +139,6 @@
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkHBox" id="hbox10">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property>
<child>
<widget class="GtkFileChooserButton" id="torrent_files_button">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="action">select-folder</property>
<property name="title" translatable="yes">Select A Folder</property>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_torrents_path">
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
@ -231,21 +192,6 @@
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_copy_torrent_file">
<property name="label" translatable="yes">Copy of .torrent files to:</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
@ -309,6 +255,77 @@
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_copy_torrent_file">
<property name="label" translatable="yes">Copy of .torrent files to:</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkHBox" id="hbox10">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property>
<child>
<widget class="GtkFileChooserButton" id="torrent_files_button">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="action">select-folder</property>
<property name="title" translatable="yes">Select A Folder</property>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_torrents_path">
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="invisible_char">&#x25CF;</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_del_copy_torrent_file">
<property name="label" translatable="yes">Delete copy of torrent file on remove</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip" translatable="yes">Delete the copy of the torrent file created when the torrent is removed</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_padding">15</property>
</packing>
</child>
</widget>
</child>
</widget>

View File

@ -220,6 +220,8 @@ class Preferences(component.Component):
("filename", self.core_config["move_completed_path"]),
"chk_copy_torrent_file": \
("active", self.core_config["copy_torrent_file"]),
"chk_del_copy_torrent_file": \
("active", self.core_config["del_copy_torrent_file"]),
"torrent_files_button": \
("filename", self.core_config["torrentfiles_location"]),
"chk_autoadd": \
@ -372,6 +374,7 @@ class Preferences(component.Component):
"chk_move_completed",
"move_completed_path_button",
"chk_copy_torrent_file",
"chk_del_copy_torrent_file",
"torrent_files_button",
"chk_autoadd",
"folder_autoadd",
@ -514,6 +517,8 @@ class Preferences(component.Component):
self.glade.get_widget("chk_focus_dialog").get_active()
new_core_config["copy_torrent_file"] = \
self.glade.get_widget("chk_copy_torrent_file").get_active()
new_core_config["del_copy_torrent_file"] = \
self.glade.get_widget("chk_del_copy_torrent_file").get_active()
new_core_config["move_completed"] = \
self.glade.get_widget("chk_move_completed").get_active()
if client.is_localhost():
@ -773,7 +778,8 @@ class Preferences(component.Component):
"radio_open_folder_custom": {"combo_file_manager": False,
"txt_open_folder_location": True},
"chk_move_completed" : {"move_completed_path_button" : True},
"chk_copy_torrent_file" : {"torrent_files_button" : True},
"chk_copy_torrent_file" : {"torrent_files_button" : True,
"chk_del_copy_torrent_file" : True},
"chk_autoadd" : {"folder_autoadd" : True},
"chk_seed_ratio" : {"spin_share_ratio": True,
"chk_remove_ratio" : True}