2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-15 21:17:07 +00:00

better errors for drawings parsing & upload

This commit is contained in:
Philip Sargent
2022-03-05 20:29:01 +00:00
parent 88f5df0f19
commit a3a65524b8
3 changed files with 48 additions and 24 deletions

View File

@@ -109,12 +109,12 @@ def dwgupload(request, folder=None, gitdisable='no'):
We use get_or_create instead of simply creating a new object in case someone uploads the same file
several times in one session, and expects them to be overwritten in the database. Although
the actual file will be duplicated in the filesystem with different random name ammendation.
the actual file will be duplicated in the filesystem with different random name ending.
'''
def dwgvalid(name):
if name in [ '.gitignore', '.hgignore', ]:
if name in [ '.gitignore', ]:
return False
if Path(name).suffix.lower() in ['.xml', '.th', '.th2', '', '.svg', '.jpg', '.pdf', 'jpeg']:
if Path(name).suffix.lower() in ['.xml', '.th', '.th2', '', '.svg', '.jpg', '.pdf', '.jpeg', '.txt']:
return True # dangerous, we should check the actual file binary signature
return False
@@ -163,10 +163,11 @@ def dwgupload(request, folder=None, gitdisable='no'):
dwgfile.save()
else:
refused.append(f.name)
print(f'REFUSED {f.name}')
if actual_saved: # maybe all were refused by the suffix test in dwgvalid()
filesaved = True
if gitdisable != 'yes':
subprocess.call([git, "commit", "-m", 'dwgupload'], cwd=dirpath)
subprocess.call([git, "commit", "-m", f'Drawings upload - {list(multiple)}'], cwd=dirpath)
files = []