Skip to content

Commit

Permalink
ensure that we dont makedirs unless path does not exist
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsochat@stanford.edu>
  • Loading branch information
vsoch committed Oct 12, 2020
1 parent b627f8f commit a4eecf8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion django_oci/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def finish_blob(
settings.MEDIA_ROOT, "blobs", blob.repository.name, digest
)
if not os.path.exists(final_path):
os.makedirs(os.path.dirname(final_path))
dirname = os.path.dirname(final_path)
if not os.path.exists(dirname):
os.makedirs(dirname)
shutil.move(blob.datafile.path, final_path)
else:
os.remove(blob.datafile.name)
Expand Down

0 comments on commit a4eecf8

Please sign in to comment.