diff --git a/ChangeLog b/ChangeLog
index c2ced8fa4..e4ee3c880 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py
index 13340a5ea..511b4309b 100644
--- a/deluge/core/preferencesmanager.py
+++ b/deluge/core/preferencesmanager.py
@@ -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,
diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index 108d27e8e..e0a42c553 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -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]
diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade
index b8921b320..b4a8a966e 100644
--- a/deluge/ui/gtkui/glade/preferences_dialog.glade
+++ b/deluge/ui/gtkui/glade/preferences_dialog.glade
@@ -106,7 +106,7 @@
True
- 4
+ 5
2
@@ -139,45 +139,6 @@
-
- 1
- 2
- 3
- 4
-
-
-
-
- True
- GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
-
-
- True
- GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- 5
-
-
- True
- GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- select-folder
- Select A Folder
-
-
- 0
-
-
-
-
- True
- GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
-
-
- 1
-
-
-
-
-
1
2
@@ -231,21 +192,6 @@
True
-
- 3
- 4
- GTK_FILL
-
-
-
-
- Copy of .torrent files to:
- True
- True
- False
- True
-
-
2
3
@@ -309,6 +255,77 @@
GTK_FILL
+
+
+ Copy of .torrent files to:
+ True
+ True
+ False
+ True
+
+
+
+ 3
+ 4
+ GTK_FILL
+
+
+
+
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+
+
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ 5
+
+
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ select-folder
+ Select A Folder
+
+
+ 0
+
+
+
+
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ ●
+
+
+ 1
+
+
+
+
+
+
+ 1
+ 2
+ 3
+ 4
+
+
+
+
+ Delete copy of torrent file on remove
+ True
+ True
+ False
+ Delete the copy of the torrent file created when the torrent is removed
+ True
+
+
+ 2
+ 4
+ 5
+ 15
+
+
diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py
index b7b4715d9..582724616 100644
--- a/deluge/ui/gtkui/preferences.py
+++ b/deluge/ui/gtkui/preferences.py
@@ -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}