Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P152
(An Untitled Masterwork)
Active
Public
Actions
Authored by
seirl
on Mar 28 2017, 4:56 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
diff --git a/swh/objstorage/objstorage_pathslicing.py b/swh/objstorage/objstorage_pathslicing.py
index 897a5f7..5a897e8 100644
--- a/swh/objstorage/objstorage_pathslicing.py
+++ b/swh/objstorage/objstorage_pathslicing.py
@@ -37,12 +38,6 @@ def _write_obj_file(hex_obj_id, objstorage):
Yields:
a file-like object open for writing bytes.
"""
- # Get the final paths and create the directory if absent.
- dir = objstorage._obj_dir(hex_obj_id)
- if not os.path.isdir(dir):
- os.makedirs(dir, DIR_MODE, exist_ok=True)
- path = os.path.join(dir, hex_obj_id)
-
# Create a temporary file.
(tmp, tmp_path) = tempfile.mkstemp(suffix='.tmp', prefix='hex_obj_id.',
dir=dir)
@@ -54,6 +49,13 @@ def _write_obj_file(hex_obj_id, objstorage):
# Then close the temporary file and move it to the right directory.
tmp_f.close()
+
+ # Get the final paths and create the directory if absent.
+ dir = objstorage._obj_dir(hex_obj_id)
+ if not os.path.isdir(dir):
+ os.makedirs(dir, DIR_MODE, exist_ok=True)
+ path = os.path.join(dir, hex_obj_id)
+
os.chmod(tmp_path, FILE_MODE)
os.rename(tmp_path, path)
Event Timeline
seirl
created this paste.
Mar 28 2017, 4:56 PM
2017-03-28 16:56:43 (UTC+2)
Log In to Comment