Ticket #1063: deluge-delete.2.patch

File deluge-delete.2.patch, 16.3 KB (added by Ghent, 14 years ago)
  • deluge/core/torrentmanager.py

     
    532532        # Remove the .torrent file in the state 
    533533        self.torrents[torrent_id].delete_torrentfile() 
    534534 
     535        # Remove the torrent file from the user specified directory 
     536        filename = self.torrents[torrent_id].filename 
     537        if self.config["copy_torrent_file"] \ 
     538            and self.config["del_copy_torrent_file"] \ 
     539            and filename: 
     540            try: 
     541                users_torrent_file = os.path.join( 
     542                    self.config["torrentfiles_location"], 
     543                    filename) 
     544                log.info("Delete user's torrent file: %s", 
     545                    users_torrent_file) 
     546                os.remove(users_torrent_file) 
     547            except Exception, e: 
     548                log.warning("Unable to remove copy torrent file: %s", e) 
     549 
    535550        # Remove the torrent from deluge's session 
    536551        try: 
    537552            del self.torrents[torrent_id] 
  • deluge/core/preferencesmanager.py

     
    5858    "listen_ports": [6881, 6891], 
    5959    "listen_interface": "", 
    6060    "copy_torrent_file": False, 
     61    "del_copy_torrent_file": False, 
    6162    "torrentfiles_location": deluge.common.get_default_download_dir(), 
    6263    "plugins_location": os.path.join(deluge.configmanager.get_config_dir(), "plugins"), 
    6364    "prioritize_first_last_pieces": False, 
  • deluge/ui/gtkui/preferences.py

     
    220220                    ("filename", self.core_config["move_completed_path"]), 
    221221                "chk_copy_torrent_file": \ 
    222222                    ("active", self.core_config["copy_torrent_file"]), 
     223                "chk_del_copy_torrent_file": \ 
     224                    ("active", self.core_config["del_copy_torrent_file"]), 
    223225                "torrent_files_button": \ 
    224226                    ("filename", self.core_config["torrentfiles_location"]), 
    225227                "chk_autoadd": \ 
     
    372374                "chk_move_completed", 
    373375                "move_completed_path_button", 
    374376                "chk_copy_torrent_file", 
     377                "chk_del_copy_torrent_file", 
    375378                "torrent_files_button", 
    376379                "chk_autoadd", 
    377380                "folder_autoadd", 
     
    542545            self.glade.get_widget("chk_focus_dialog").get_active() 
    543546        new_core_config["copy_torrent_file"] = \ 
    544547            self.glade.get_widget("chk_copy_torrent_file").get_active() 
     548        new_core_config["del_copy_torrent_file"] = \ 
     549            self.glade.get_widget("chk_del_copy_torrent_file").get_active() 
    545550        new_core_config["move_completed"] = \ 
    546551            self.glade.get_widget("chk_move_completed").get_active() 
    547552        if client.is_localhost(): 
     
    827832                "radio_open_folder_custom": {"combo_file_manager": False, 
    828833                                             "txt_open_folder_location": True}, 
    829834                "chk_move_completed" : {"move_completed_path_button" : True}, 
    830                 "chk_copy_torrent_file" : {"torrent_files_button" : True}, 
     835                "chk_copy_torrent_file" : {"torrent_files_button" : True, 
     836                                           "chk_del_copy_torrent_file" : True}, 
    831837                "chk_autoadd" : {"folder_autoadd" : True}, 
    832838                "chk_seed_ratio" : {"spin_share_ratio": True, 
    833839                                    "chk_remove_ratio" : True} 
  • deluge/ui/gtkui/glade/preferences_dialog.glade

     
    106106                                    <child> 
    107107                                      <widget class="GtkTable" id="table9"> 
    108108                                        <property name="visible">True</property> 
    109                                         <property name="n_rows">4</property> 
     109                                        <property name="n_rows">5</property> 
    110110                                        <property name="n_columns">2</property> 
    111111                                        <child> 
    112112                                          <widget class="GtkAlignment" id="alignment11"> 
     
    142142                                          <packing> 
    143143                                            <property name="left_attach">1</property> 
    144144                                            <property name="right_attach">2</property> 
    145                                             <property name="top_attach">3</property> 
    146                                             <property name="bottom_attach">4</property> 
    147                                           </packing> 
    148                                         </child> 
    149                                         <child> 
    150                                           <widget class="GtkAlignment" id="alignment8"> 
    151                                             <property name="visible">True</property> 
    152                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> 
    153                                             <child> 
    154                                               <widget class="GtkHBox" id="hbox10"> 
    155                                                 <property name="visible">True</property> 
    156                                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> 
    157                                                 <property name="spacing">5</property> 
    158                                                 <child> 
    159                                                   <widget class="GtkFileChooserButton" id="torrent_files_button"> 
    160                                                     <property name="visible">True</property> 
    161                                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> 
    162                                                     <property name="action">select-folder</property> 
    163                                                     <property name="title" translatable="yes">Select A Folder</property> 
    164                                                   </widget> 
    165                                                   <packing> 
    166                                                     <property name="position">0</property> 
    167                                                   </packing> 
    168                                                 </child> 
    169                                                 <child> 
    170                                                   <widget class="GtkEntry" id="entry_torrents_path"> 
    171                                                     <property name="can_focus">True</property> 
    172                                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> 
    173                                                   </widget> 
    174                                                   <packing> 
    175                                                     <property name="position">1</property> 
    176                                                   </packing> 
    177                                                 </child> 
    178                                               </widget> 
    179                                             </child> 
    180                                           </widget> 
    181                                           <packing> 
    182                                             <property name="left_attach">1</property> 
    183                                             <property name="right_attach">2</property> 
    184145                                            <property name="top_attach">2</property> 
    185146                                            <property name="bottom_attach">3</property> 
    186147                                          </packing> 
     
    232193                                            <signal name="toggled" handler="on_toggle"/> 
    233194                                          </widget> 
    234195                                          <packing> 
    235                                             <property name="top_attach">3</property> 
    236                                             <property name="bottom_attach">4</property> 
    237                                             <property name="x_options">GTK_FILL</property> 
    238                                           </packing> 
    239                                         </child> 
    240                                         <child> 
    241                                           <widget class="GtkCheckButton" id="chk_copy_torrent_file"> 
    242                                             <property name="label" translatable="yes">Copy of .torrent files to:</property> 
    243                                             <property name="visible">True</property> 
    244                                             <property name="can_focus">True</property> 
    245                                             <property name="receives_default">False</property> 
    246                                             <property name="draw_indicator">True</property> 
    247                                             <signal name="toggled" handler="on_toggle"/> 
    248                                           </widget> 
    249                                           <packing> 
    250196                                            <property name="top_attach">2</property> 
    251197                                            <property name="bottom_attach">3</property> 
    252198                                            <property name="x_options">GTK_FILL</property> 
     
    309255                                            <property name="x_options">GTK_FILL</property> 
    310256                                          </packing> 
    311257                                        </child> 
     258                                        <child> 
     259                                          <widget class="GtkCheckButton" id="chk_copy_torrent_file"> 
     260                                            <property name="label" translatable="yes">Copy of .torrent files to:</property> 
     261                                            <property name="visible">True</property> 
     262                                            <property name="can_focus">True</property> 
     263                                            <property name="receives_default">False</property> 
     264                                            <property name="draw_indicator">True</property> 
     265                                            <signal name="toggled" handler="on_toggle"/> 
     266                                          </widget> 
     267                                          <packing> 
     268                                            <property name="top_attach">3</property> 
     269                                            <property name="bottom_attach">4</property> 
     270                                            <property name="x_options">GTK_FILL</property> 
     271                                          </packing> 
     272                                        </child> 
     273                                        <child> 
     274                                          <widget class="GtkAlignment" id="alignment8"> 
     275                                            <property name="visible">True</property> 
     276                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> 
     277                                            <child> 
     278                                              <widget class="GtkHBox" id="hbox10"> 
     279                                                <property name="visible">True</property> 
     280                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> 
     281                                                <property name="spacing">5</property> 
     282                                                <child> 
     283                                                  <widget class="GtkFileChooserButton" id="torrent_files_button"> 
     284                                                    <property name="visible">True</property> 
     285                                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> 
     286                                                    <property name="action">select-folder</property> 
     287                                                    <property name="title" translatable="yes">Select A Folder</property> 
     288                                                  </widget> 
     289                                                  <packing> 
     290                                                    <property name="position">0</property> 
     291                                                  </packing> 
     292                                                </child> 
     293                                                <child> 
     294                                                  <widget class="GtkEntry" id="entry_torrents_path"> 
     295                                                    <property name="can_focus">True</property> 
     296                                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> 
     297                                                    <property name="invisible_char">&#x25CF;</property> 
     298                                                  </widget> 
     299                                                  <packing> 
     300                                                    <property name="position">1</property> 
     301                                                  </packing> 
     302                                                </child> 
     303                                              </widget> 
     304                                            </child> 
     305                                          </widget> 
     306                                          <packing> 
     307                                            <property name="left_attach">1</property> 
     308                                            <property name="right_attach">2</property> 
     309                                            <property name="top_attach">3</property> 
     310                                            <property name="bottom_attach">4</property> 
     311                                          </packing> 
     312                                        </child> 
     313                                        <child> 
     314                                          <widget class="GtkCheckButton" id="chk_del_copy_torrent_file"> 
     315                                            <property name="label" translatable="yes">Delete copy of torrent file on remove</property> 
     316                                            <property name="visible">True</property> 
     317                                            <property name="can_focus">True</property> 
     318                                            <property name="receives_default">False</property> 
     319                                            <property name="tooltip" translatable="yes">Delete the copy of the torrent file created when the torrent is removed</property> 
     320                                            <property name="draw_indicator">True</property> 
     321                                          </widget> 
     322                                          <packing> 
     323                                            <property name="right_attach">2</property> 
     324                                            <property name="top_attach">4</property> 
     325                                            <property name="bottom_attach">5</property> 
     326                                            <property name="x_padding">15</property> 
     327                                          </packing> 
     328                                        </child> 
    312329                                      </widget> 
    313330                                    </child> 
    314331                                  </widget>