Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion mongodb_consistent_backup/State.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from time import time

from mongodb_consistent_backup.Common import Lock
from mongodb_consistent_backup.Errors import OperationError


class StateBase(object):
Expand All @@ -22,7 +23,14 @@ def __init__(self, base_dir, config, filename="meta.bson", state_version=1, meta
self.lock = Lock(self.state_lock, False)

if not os.path.isdir(self.state_dir):
os.makedirs(self.state_dir)
# try normal mkdir first, fallback to recursive mkdir if there is an exception
try:
os.mkdir(self.state_dir)
except:
try:
os.makedirs(self.state_dir)
except Exception, e:
raise OperationError(e)

def merge(self, new, old):
merged = old.copy()
Expand Down