diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-03-03 13:00:37 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-03-03 13:00:37 +0000 |
commit | 58e5559b67d707377a845cda1cdd8f95be5f1bb7 (patch) | |
tree | e5259d7aba00bc066322a00894bf5ec5f7aff950 | |
parent | 008cd18050cee2f9ae676f483eb1880fe86b0f5d (diff) | |
download | obnam-58e5559b67d707377a845cda1cdd8f95be5f1bb7.tar.gz |
Fix creation of LocalFS baseurl race condition
If we have many clients running concurrently, they might all
be creating, say, the chunks directory, and with the old code
only one of them would succeed, and the others would fail,
for not good reason. The new could should deal with that.
-rw-r--r-- | obnamlib/vfs_local.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/obnamlib/vfs_local.py b/obnamlib/vfs_local.py index 56cd1c8f..00ca1f86 100644 --- a/obnamlib/vfs_local.py +++ b/obnamlib/vfs_local.py @@ -67,7 +67,13 @@ class LocalFS(obnamlib.VirtualFileSystem): if not self.isdir('.'): if create: tracing.trace('creating %s', baseurl) - os.mkdir(baseurl) + try: + os.mkdir(baseurl) + except OSError, e: # pragma: no cover + # The directory might have been created concurrently + # by someone else! + if e.errno != errno.EEXIST: + raise else: raise OSError(errno.ENOENT, self.cwd) |