objectstore: use 'tmp' subdir for temp directories
Instead of creating temporary directories at the root of the store create them in a sub-directory called 'tmp'. This should make it easy to cleanup left-over (temporary) dirs in case of crashes. Additionally, it has the nice side effect that it is possible to check that there are no objects that are still in-flight, i.e. not cleaned-up.
This commit is contained in:
parent
01d989e718
commit
5fbf5bb431
1 changed files with 3 additions and 1 deletions
|
|
@ -207,9 +207,11 @@ class ObjectStore:
|
||||||
self.store = store
|
self.store = store
|
||||||
self.objects = f"{store}/objects"
|
self.objects = f"{store}/objects"
|
||||||
self.refs = f"{store}/refs"
|
self.refs = f"{store}/refs"
|
||||||
|
self.tmp = f"{store}/tmp"
|
||||||
os.makedirs(self.store, exist_ok=True)
|
os.makedirs(self.store, exist_ok=True)
|
||||||
os.makedirs(self.objects, exist_ok=True)
|
os.makedirs(self.objects, exist_ok=True)
|
||||||
os.makedirs(self.refs, exist_ok=True)
|
os.makedirs(self.refs, exist_ok=True)
|
||||||
|
os.makedirs(self.tmp, exist_ok=True)
|
||||||
|
|
||||||
def contains(self, object_id):
|
def contains(self, object_id):
|
||||||
if not object_id:
|
if not object_id:
|
||||||
|
|
@ -224,7 +226,7 @@ class ObjectStore:
|
||||||
|
|
||||||
def tempdir(self, prefix=None, suffix=None):
|
def tempdir(self, prefix=None, suffix=None):
|
||||||
"""Return a tempfile.TemporaryDirectory within the store"""
|
"""Return a tempfile.TemporaryDirectory within the store"""
|
||||||
return tempfile.TemporaryDirectory(dir=self.store,
|
return tempfile.TemporaryDirectory(dir=self.tmp,
|
||||||
prefix=prefix,
|
prefix=prefix,
|
||||||
suffix=suffix)
|
suffix=suffix)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue