Ticket #2466: [#2466][AutoAdd] Error in copy torrent code if inital rename fails patchv2.patch

File [#2466][AutoAdd] Error in copy torrent code if inital rename fails patchv2.patch, 2.1 KB (added by Doadin, 10 years ago)
  • deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py

    From 110931a580d698a261a014f9deba57a173839ab5 Mon Sep 17 00:00:00 2001
    From: doadin <tbkizle@gmail.com>
    Date: Fri, 4 Jul 2014 01:02:21 -0400
    Subject: [PATCH] Update core.py
    
    ---
     .../plugins/AutoAdd/deluge/plugins/autoadd/core.py | 23 ++--------------------
     1 file changed, 2 insertions(+), 21 deletions(-)
    
    diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py
    index c11fe64..d9ed97a 100644
    a b def update_watchdir(self, watchdir_id): 
    335335                    copy_torrent_file = os.path.join(copy_torrent_path, filename) 
    336336                    log.debug("Moving added torrent file \"%s\" to \"%s\"", 
    337337                              os.path.basename(filepath), copy_torrent_path) 
    338                     try: 
    339                         shutil.move(filepath, copy_torrent_file) 
    340                     except OSError, why: 
    341                         from errno import EXDEV 
    342                         if why.errno == errno.EXDEV: 
    343                             # This can happen for different mount points 
    344                             from shutil import copyfile 
    345                             try: 
    346                                 copyfile(filepath, copy_torrent_file) 
    347                                 os.remove(filepath) 
    348                             except OSError: 
    349                                 # Last Resort! 
    350                                 try: 
    351                                     open(copy_torrent_file, 'wb').write( 
    352                                         open(filepath, 'rb').read() 
    353                                     ) 
    354                                     os.remove(filepath) 
    355                                 except OSError, why: 
    356                                     raise why 
    357                         else: 
    358                             raise why 
     338                    shutil.move(filepath, copy_torrent_file) 
     339 
    359340                else: 
    360341                    os.remove(filepath) 
    361342