summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-08-15 19:01:10 +0100
committerLars Wirzenius <liw@liw.fi>2013-08-15 19:01:10 +0100
commitddf67bb69784c3084cb0e38ad988f402ce012cfe (patch)
tree71330c8d2bf4bf291f8ed372fd6de9a26227f7c6
parent486c86999b8fda82bbc432bcfffd1bd098995b40 (diff)
downloadobnam-ddf67bb69784c3084cb0e38ad988f402ce012cfe.tar.gz
SFTP write_file handles EACCESS as ENOENT
Patch by Armin Größlinger.
-rw-r--r--NEWS4
-rw-r--r--obnamlib/plugins/sftp_plugin.py8
2 files changed, 11 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 8083787f..427efec4 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,10 @@ Bug fixes:
extra files, such as "lock" (left there by a previous, crashed Obnam
run). It no longer does. Fix by Lars Kruse.
+* The SFTP plugin now handles another error code (EACCESS) when writing
+ a file and the directory it should go into not existing. Patch by
+ Armin Größlinger.
+
Version 1.5, released 2013-08-08
--------------------------------
diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py
index a4d12fa9..8b78f55c 100644
--- a/obnamlib/plugins/sftp_plugin.py
+++ b/obnamlib/plugins/sftp_plugin.py
@@ -529,7 +529,13 @@ class SftpFS(obnamlib.VirtualFileSystem):
try:
f = self.open(pathname, 'wx')
except (IOError, OSError), e:
- if e.errno != errno.ENOENT:
+ # When the path to the file to be written does not
+ # exist, we try to create the directories below. Note that
+ # some SFTP servers return EACCES instead of ENOENT
+ # when the path to the file does not exist, so we
+ # do not raise an exception here for both ENOENT
+ # and EACCES.
+ if e.errno != errno.ENOENT and e.errno != errno.EACCES:
raise
dirname = os.path.dirname(pathname)
self.makedirs(dirname)