summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-12-27 23:16:20 +0000
committerLars Wirzenius <liw@liw.fi>2010-12-27 23:16:20 +0000
commita387b6d9e59c6b25cad87e5eae9e2ae6d5b8f5fe (patch)
tree96e4d9cd68d26ca358a0334efb432e0e4a2f68ce
parent22de653b932336d56b591d342336832ff4511f03 (diff)
downloadobnam-a387b6d9e59c6b25cad87e5eae9e2ae6d5b8f5fe.tar.gz
Fix LocalFS to raise error if connecting to non-existent directory.
SftpFS already does this. Consistency here is good.
-rw-r--r--obnamlib/store_tests.py1
-rw-r--r--obnamlib/vfs.py3
-rw-r--r--obnamlib/vfs_local.py2
3 files changed, 6 insertions, 0 deletions
diff --git a/obnamlib/store_tests.py b/obnamlib/store_tests.py
index a2e1fe9a..f880383d 100644
--- a/obnamlib/store_tests.py
+++ b/obnamlib/store_tests.py
@@ -595,6 +595,7 @@ class StoreGenspecTests(unittest.TestCase):
self.tempdir = tempfile.mkdtemp()
storedir = os.path.join(self.tempdir, 'store')
+ os.mkdir(storedir)
fs = obnamlib.LocalFS(storedir)
self.store = obnamlib.Store(fs, obnamlib.DEFAULT_NODE_SIZE,
obnamlib.DEFAULT_UPLOAD_QUEUE_SIZE,
diff --git a/obnamlib/vfs.py b/obnamlib/vfs.py
index 6933951d..6f99d8fe 100644
--- a/obnamlib/vfs.py
+++ b/obnamlib/vfs.py
@@ -280,6 +280,9 @@ class VfsTests(object): # pragma: no cover
self.fs.reinit(self.fs.baseurl)
self.assertEqual(self.fs.getcwd(), self.basepath)
+ def test_reinit_to_nonexistent_filename_raises_OSError(self):
+ self.assertRaises(OSError, self.fs.reinit, '/thisdoesnotexist')
+
def test_getcwd_returns_dirname(self):
self.assertEqual(self.fs.getcwd(), self.basepath)
diff --git a/obnamlib/vfs_local.py b/obnamlib/vfs_local.py
index 13726499..b9b039bb 100644
--- a/obnamlib/vfs_local.py
+++ b/obnamlib/vfs_local.py
@@ -55,6 +55,8 @@ class LocalFS(obnamlib.VirtualFileSystem):
# perception of current working directory. This also benefits
# unit tests. To do this, we store the baseurl as the cwd.
self.cwd = os.path.abspath(baseurl)
+ if not self.isdir('.'):
+ raise OSError(errno.ENOENT, self.cwd)
def close(self):
logging.info('VFS %s closing down; bytes_read=%d bytes_written=%d' %