← Back to team overview

duplicity-team team mailing list archive

[Merge] lp:~tblue/duplicity/paramiko-fix-delete-retry into lp:duplicity

 

Tilman Blumenbach has proposed merging lp:~tblue/duplicity/paramiko-fix-delete-retry into lp:duplicity.

Requested reviews:
  duplicity-team (duplicity-team)
Related bugs:
  Bug #1115715 in Duplicity: "Paramiko backend: delete() always fails if --num-retries > 1"
  https://bugs.launchpad.net/duplicity/+bug/1115715

For more details, see:
https://code.launchpad.net/~tblue/duplicity/paramiko-fix-delete-retry/+merge/159992

This fixes bug #1115715, which is really annoying. Basically it makes using the Paramiko backend with the default settings impossible.
-- 
https://code.launchpad.net/~tblue/duplicity/paramiko-fix-delete-retry/+merge/159992
Your team duplicity-team is requested to review the proposed merge of lp:~tblue/duplicity/paramiko-fix-delete-retry into lp:duplicity.
=== modified file 'duplicity/backends/_ssh_paramiko.py'
--- duplicity/backends/_ssh_paramiko.py	2012-09-19 04:55:59 +0000
+++ duplicity/backends/_ssh_paramiko.py	2013-04-21 23:04:25 +0000
@@ -352,12 +352,10 @@
     def delete(self, filename_list):
         """deletes all files in the list on the remote side. In scp mode unavoidable quoting issues
         will cause failures if filenames containing single quotes are encountered."""
-        for n in range(1, globals.num_retries+1):
-            if n > 1:
-                # sleep before retry
-                time.sleep(self.retry_delay)
-            try:
-                for fn in filename_list:
+        for fn in filename_list:
+            # Try to delete each file several times before giving up completely.
+            for n in range(1, globals.num_retries+1):
+                try:
                     if (globals.use_scp):
                         self.runremote("rm '%s/%s'" % (self.remote_dir,fn),False,"scp rm ")
                     else:
@@ -365,11 +363,15 @@
                             self.sftp.remove(fn)
                         except Exception, e:
                             raise BackendException("sftp rm %s failed: %s" % (fn,e))
-            except Exception, e:
-                if n == globals.num_retries:
-                    log.FatalError(str(e), log.ErrorCode.backend_error)
-                else:
-                    log.Warn("%s (Try %d of %d) Will retry in %d seconds." % (e,n,globals.num_retries,self.retry_delay))
+
+                    # If we get here, we deleted this file successfully. Move on to the next one.
+                    break
+                except Exception, e:
+                    if n == globals.num_retries:
+                        log.FatalError(str(e), log.ErrorCode.backend_error)
+                    else:
+                        log.Warn("%s (Try %d of %d) Will retry in %d seconds." % (e,n,globals.num_retries,self.retry_delay))
+                        time.sleep(self.retry_delay)
 
     def runremote(self,cmd,ignoreexitcode=False,errorprefix=""):
         """small convenience function that opens a shell channel, runs remote command and returns


Follow ups