Safe disk write for content.json files

This commit is contained in:
shortcutme 2017-01-05 02:26:44 +01:00
parent c94e73a029
commit d9f8e83429

View file

@ -166,8 +166,11 @@ class SiteStorage(object):
with open(file_path, "wb") as file: with open(file_path, "wb") as file:
shutil.copyfileobj(content, file) # Write buff to disk shutil.copyfileobj(content, file) # Write buff to disk
else: # Simple string else: # Simple string
with open(file_path, "wb") as file: if inner_path == "content.json" and os.path.isfile(file_path):
file.write(content) helper.atomicWrite(file_path, content)
else:
with open(file_path, "wb") as file:
file.write(content)
del content del content
self.onUpdated(inner_path) self.onUpdated(inner_path)