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:
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user