fixed many problems in creating new entrances

This commit is contained in:
2023-11-07 02:12:57 +02:00
parent bd0a9332df
commit 07d9365747
8 changed files with 136 additions and 53 deletions

View File

@@ -152,6 +152,8 @@ def write_and_commit(files, message):
# GIT see also core/views/uploads.py dwgupload()
# GIT see also core/views/expo.py editexpopage()
os.makedirs(os.path.dirname(filepath), exist_ok = True)
if filepath.is_dir():
return False
if encoding:
mode = "w"
kwargs = {"encoding": encoding}
@@ -160,7 +162,7 @@ def write_and_commit(files, message):
kwargs = {}
try:
with open(filepath, mode, **kwargs) as f:
print(f"WRITING {cwd}---{filename} ")
print(f"WRITING {cwd}/{filename} ")
f.write(content)
except PermissionError:
raise WriteAndCommitError(
@@ -226,6 +228,7 @@ def write_and_commit(files, message):
raise WriteAndCommitError(
f"CANNOT git on server for this file {filename}. Subprocess error. Edits not saved.\nAsk a nerd to fix this."
)
return True
class WriteAndCommitError(Exception):