Use thread-safe mode to create directories

This commit is contained in:
shortcutme 2019-12-17 14:18:54 +01:00
parent 1be56b5a39
commit 2a402a0674
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 16 additions and 12 deletions

View file

@ -406,9 +406,7 @@ class SiteStoragePlugin(object):
def createSparseFile(self, inner_path, size, sha512=None):
file_path = self.getPath(inner_path)
file_dir = os.path.dirname(file_path)
if not os.path.isdir(file_dir):
os.makedirs(file_dir)
self.ensureDir(os.path.dirname(file_path))
f = open(file_path, 'wb')
f.truncate(min(1024 * 1024 * 5, size)) # Only pre-allocate up to 5MB
@ -432,9 +430,7 @@ class SiteStoragePlugin(object):
file_path = self.getPath(inner_path)
# Create dir if not exist
file_dir = os.path.dirname(file_path)
if not os.path.isdir(file_dir):
os.makedirs(file_dir)
self.ensureDir(os.path.dirname(inner_path))
if not os.path.isfile(file_path):
file_info = self.site.content_manager.getFileInfo(inner_path)