summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-03-22 14:52:11 +0200
committerLars Wirzenius <liw@liw.fi>2015-03-22 14:52:11 +0200
commitfb7af7bb6f2a3216494a252c9fd59577ff26790d (patch)
tree8ae7515690f04acfc0aa193334a2692066181af1
parent3f26b67de13e419ac9436b2caf1ef85171a76017 (diff)
downloadobnam-fb7af7bb6f2a3216494a252c9fd59577ff26790d.tar.gz
Fix SFTP stat result fields from None to 0
Found by Laurence Perkins.
-rw-r--r--obnamlib/plugins/sftp_plugin.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py
index 59d83ecd..cebd2ab0 100644
--- a/obnamlib/plugins/sftp_plugin.py
+++ b/obnamlib/plugins/sftp_plugin.py
@@ -407,6 +407,18 @@ class SftpFS(obnamlib.VirtualFileSystem):
return timestamp
def _fix_stat(self, pathname, st):
+ # Laurence Perkins found that the Tahoe-LAFS SFTP server
+ # returns "None" for st_size. We replace None values with
+ # zeroes, to avoid sprinkling Obnam code with tests for None.
+ st.st_atime = st.st_atime or 0
+ st.st_ctime = st.st_ctime or 0
+ st.st_mtime = st.st_mtime or 0
+ st.st_mode = st.st_mode or 0
+ st.st_size = st.st_size or 0
+ st.st_blksize = st.st_blksize or 0
+ st.st_gid = st.st_gid or 0
+ st.st_uid = st.st_uid or 0
+
# SFTP and/or paramiko fail to return some of the required fields,
# so we add them, using faked data.
defaults = {