Author: andar

Revision: 6009

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

Diff:
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2009-12-11 20:45:59 UTC (rev 6008)
+++ trunk/ChangeLog     2009-12-11 21:00:12 UTC (rev 6009)
@@ -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

Modified: trunk/deluge/core/preferencesmanager.py
===================================================================
--- trunk/deluge/core/preferencesmanager.py     2009-12-11 20:45:59 UTC (rev 
6008)
+++ trunk/deluge/core/preferencesmanager.py     2009-12-11 21:00:12 UTC (rev 
6009)
@@ -58,6 +58,7 @@
     "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,

Modified: trunk/deluge/core/torrentmanager.py
===================================================================
--- trunk/deluge/core/torrentmanager.py 2009-12-11 20:45:59 UTC (rev 6008)
+++ trunk/deluge/core/torrentmanager.py 2009-12-11 21:00:12 UTC (rev 6009)
@@ -532,6 +532,21 @@
         # 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]

Modified: trunk/deluge/ui/gtkui/glade/preferences_dialog.glade
===================================================================
--- trunk/deluge/ui/gtkui/glade/preferences_dialog.glade        2009-12-11 
20:45:59 UTC (rev 6008)
+++ trunk/deluge/ui/gtkui/glade/preferences_dialog.glade        2009-12-11 
21:00:12 UTC (rev 6009)
@@ -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">
@@ -142,45 +142,6 @@
                                           <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>
                                             <property 
name="top_attach">2</property>
                                             <property 
name="bottom_attach">3</property>
                                           </packing>
@@ -232,21 +193,6 @@
                                             <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>
                                             <property 
name="x_options">GTK_FILL</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>

Modified: trunk/deluge/ui/gtkui/preferences.py
===================================================================
--- trunk/deluge/ui/gtkui/preferences.py        2009-12-11 20:45:59 UTC (rev 
6008)
+++ trunk/deluge/ui/gtkui/preferences.py        2009-12-11 21:00:12 UTC (rev 
6009)
@@ -220,6 +220,8 @@
                     ("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 @@
                 "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 @@
             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 @@
                 "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}


--

You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.


Reply via email to