From a3a65524b86abde3bc924d611620f71f87b7bf36 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 5 Mar 2022 20:29:01 +0000 Subject: better errors for drawings parsing & upload --- core/views/uploads.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'core/views/uploads.py') diff --git a/core/views/uploads.py b/core/views/uploads.py index 2f3e053..6819e3d 100644 --- a/core/views/uploads.py +++ b/core/views/uploads.py @@ -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 = [] -- cgit v1.2.3