Merge lp:~ed.so/duplicity/debian.dav.mkdir into lp:duplicity/0.6

Proposed by edso
Status: Merged
Merged at revision: 943
Proposed branch: lp:~ed.so/duplicity/debian.dav.mkdir
Merge into: lp:duplicity/0.6
Diff against target: 52 lines (+29/-6)
1 file modified
duplicity/backends/webdavbackend.py (+29/-6)
To merge this branch: bzr merge lp:~ed.so/duplicity/debian.dav.mkdir
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+200133@code.launchpad.net

Description of the change

tested and working

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'duplicity/backends/webdavbackend.py'
2--- duplicity/backends/webdavbackend.py 2013-01-10 19:04:39 +0000
3+++ duplicity/backends/webdavbackend.py 2013-12-28 16:42:41 +0000
4@@ -272,12 +272,9 @@
5 del self.headers['Depth']
6 # if the target collection does not exist, create it.
7 if response.status == 404:
8- response.close()
9- log.Info("Directory '%s' being created." % self.directory)
10- response = self.request("MKCOL", self.directory)
11- log.Info("WebDAV MKCOL status: %s %s" % (response.status, response.reason))
12- response.close()
13- # just created folder is so return empty
14+ response.close() # otherwise next request fails with ResponseNotReady
15+ self.makedir()
16+ # just created an empty folder, so return empty
17 return []
18 elif response.status in [200, 207]:
19 document = response.read()
20@@ -301,6 +298,32 @@
21 finally:
22 if response: response.close()
23
24+ def makedir(self):
25+ """Make (nested) directories on the server."""
26+ dirs = self.directory.split("/")
27+ # url causes directory to start with /, but it might be given
28+ # with or without trailing / (which is required)
29+ if dirs[-1] == '':
30+ dirs=dirs[0:-1]
31+ for i in range(1,len(dirs)):
32+ d="/".join(dirs[0:i+1])+"/"
33+
34+ self.close() # or we get previous request's data or exception
35+ self.headers['Depth'] = "1"
36+ response = self.request("PROPFIND", d)
37+ del self.headers['Depth']
38+
39+ log.Info("Checking existence dir %s: %d" % (d, response.status))
40+
41+ if response.status == 404:
42+ log.Info("Creating missing directory %s" % d)
43+ self.close() # or we get previous request's data or exception
44+
45+ res = self.request("MKCOL", d)
46+ if res.status != 201:
47+ raise BackendException("WebDAV MKCOL %s failed: %s %s" % (d,res.status,res.reason))
48+ self.close()
49+
50 def __taste_href(self, href):
51 """
52 Internal helper to taste the given href node and, if

Subscribers

People subscribed via source and target branches

to all changes: