Merge lp:~townsend/duplicity/fix-1161599 into lp:duplicity/0.6

Proposed by Christopher Townsend
Status: Merged
Merged at revision: 912
Proposed branch: lp:~townsend/duplicity/fix-1161599
Merge into: lp:duplicity/0.6
Diff against target: 34 lines (+6/-1)
1 file modified
duplicity/backends/u1backend.py (+6/-1)
To merge this branch: bzr merge lp:~townsend/duplicity/fix-1161599
Reviewer Review Type Date Requested Status
edso Approve
Review via email: mp+159849@code.launchpad.net

Description of the change

Transient socket or HTTP errors will cause a retry of the PUT for a backup. This would then lead to 400 Bad Request errors from the server. This MP:

* Fixes the case where the file pointer to the backup file was not being set back to the beginning of the file when an error occurs. This causes subsequent retries to fail with 400 Bad Request errors from the server. This is due to a change in revno. 901 where a file handle is used instead of a bytearray.
* Fixes the removal of Content-Length from the header in revno. 901. Content-Length is required according to the Ubuntu One API documentation.

To post a comment you must log in.
Revision history for this message
edso (ed.so) wrote :

looks good to me. like that you kept the memory saving file pointer.

thanks ede/duply.net

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'duplicity/backends/u1backend.py'
2--- duplicity/backends/u1backend.py 2012-12-25 16:49:33 +0000
3+++ duplicity/backends/u1backend.py 2013-04-19 15:56:39 +0000
4@@ -84,6 +84,7 @@
5 % duplicity.util.exception_traceback())
6 if n == globals.num_retries:
7 log.FatalError("Giving up on request after %d attempts, last exception %s" % (n,e))
8+ body.seek(0) # Go to the beginning of the file for the retry
9 time.sleep(30)
10 continue
11
12@@ -105,6 +106,8 @@
13 ecode = log.ErrorCode.backend_no_space
14 elif numcode == 404:
15 ecode = log.ErrorCode.backend_not_found
16+
17+ body.seek(0) # Go to the beginning of the file for the retry
18
19 if n < globals.num_retries:
20 time.sleep(30)
21@@ -207,10 +210,12 @@
22 remote_full = self.content_base + self.quote(content['content_path'])
23 log.Info("uploading file %s to location %s" % (remote_filename, remote_full))
24
25+ size = os.path.getsize(source_path.name)
26 fh=open(source_path.name,'rb')
27
28 content_type = 'application/octet-stream'
29- headers = {"Content-Type": content_type}
30+ headers = {"Content-Length": str(size),
31+ "Content-Type": content_type}
32 resp, content = self.client.request(remote_full,
33 method="PUT",
34 body=fh,

Subscribers

People subscribed via source and target branches