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
=== modified file 'duplicity/backends/webdavbackend.py'
--- duplicity/backends/webdavbackend.py 2013-01-10 19:04:39 +0000
+++ duplicity/backends/webdavbackend.py 2013-12-28 16:42:41 +0000
@@ -272,12 +272,9 @@
272 del self.headers['Depth']272 del self.headers['Depth']
273 # if the target collection does not exist, create it.273 # if the target collection does not exist, create it.
274 if response.status == 404:274 if response.status == 404:
275 response.close()275 response.close() # otherwise next request fails with ResponseNotReady
276 log.Info("Directory '%s' being created." % self.directory)276 self.makedir()
277 response = self.request("MKCOL", self.directory)277 # just created an empty folder, so return empty
278 log.Info("WebDAV MKCOL status: %s %s" % (response.status, response.reason))
279 response.close()
280 # just created folder is so return empty
281 return []278 return []
282 elif response.status in [200, 207]:279 elif response.status in [200, 207]:
283 document = response.read()280 document = response.read()
@@ -301,6 +298,32 @@
301 finally:298 finally:
302 if response: response.close()299 if response: response.close()
303300
301 def makedir(self):
302 """Make (nested) directories on the server."""
303 dirs = self.directory.split("/")
304 # url causes directory to start with /, but it might be given
305 # with or without trailing / (which is required)
306 if dirs[-1] == '':
307 dirs=dirs[0:-1]
308 for i in range(1,len(dirs)):
309 d="/".join(dirs[0:i+1])+"/"
310
311 self.close() # or we get previous request's data or exception
312 self.headers['Depth'] = "1"
313 response = self.request("PROPFIND", d)
314 del self.headers['Depth']
315
316 log.Info("Checking existence dir %s: %d" % (d, response.status))
317
318 if response.status == 404:
319 log.Info("Creating missing directory %s" % d)
320 self.close() # or we get previous request's data or exception
321
322 res = self.request("MKCOL", d)
323 if res.status != 201:
324 raise BackendException("WebDAV MKCOL %s failed: %s %s" % (d,res.status,res.reason))
325 self.close()
326
304 def __taste_href(self, href):327 def __taste_href(self, href):
305 """328 """
306 Internal helper to taste the given href node and, if329 Internal helper to taste the given href node and, if

Subscribers

People subscribed via source and target branches

to all changes: