summaryrefslogtreecommitdiffstats
path: root/core/models/caves.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/models/caves.py')
-rw-r--r--core/models/caves.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/models/caves.py b/core/models/caves.py
index 313935a..4ecbfdb 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -40,7 +40,7 @@ todo='''- Move utility function into utils.py
def writetrogglefile(filepath, filecontent):
'''Set permissions to rw-rw-r-- and commit the new saved file to git
- Callers should handle exception PermissionsError explicitly
+ Callers to cave.writeDataFile() or entrance.writeDataFile() should handle the exception PermissionsError explicitly
'''
filepath = Path(filepath)
cwd = filepath.parent
@@ -48,8 +48,10 @@ def writetrogglefile(filepath, filecontent):
git = settings.GIT
# do not trap exceptions, pass them up to the view that called this function
+ # if the os.chmod fails, it can zero the contents of the file as a side effect. Dangerous.
with open(filepath, "w") as f:
- os.chmod(filepath, 0o664) # set file permissions to rw-rw-r--
+ f.chmod(0o664) # safely set file permissions to rw-rw-r--
+ # os.chmod(filepath, 0o664) # set file permissions to rw-rw-r--
f.write(filecontent)
print(f'WRITING{cwd}---{filename} ')
call([git, "add", filename], cwd=cwd)