failed to backup data to ssh storage
When backup data to ssh storage for the first time, because the sub directory "metadata" isn't exist in the ssh storage directory, the exception IOError will be raised. The exception IOError should be caught in the funtion listdir() of the SshStorage class, and the empty list should be returned when the errno is ENOENT which indicates "No such file or directory". The other exceptions, e.g. "Permission denied", should be raised. Change-Id: Icddca7078a47fb82c12d4232065d51e2baa0ab60 Closes-Bug: #1638816
This commit is contained in:
parent
45ff14bfda
commit
7cf0799408
|
@ -15,6 +15,7 @@ limitations under the License.
|
|||
|
||||
"""
|
||||
|
||||
import errno
|
||||
import os
|
||||
import stat
|
||||
|
||||
|
@ -98,7 +99,13 @@ class SshStorage(fslike.FsLikeStorage):
|
|||
self.ftp.put(from_path, to_path)
|
||||
|
||||
def listdir(self, directory):
|
||||
return self.ftp.listdir(directory)
|
||||
try:
|
||||
return self.ftp.listdir(directory)
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
return list()
|
||||
else:
|
||||
raise
|
||||
|
||||
def open(self, filename, mode):
|
||||
return self.ftp.open(filename, mode=mode)
|
||||
|
|
Loading…
Reference in New Issue