2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-01-19 09:22:32 +00:00

Make more robust to WSL chmod failures for tests

This commit is contained in:
Philip Sargent 2022-04-06 20:43:26 +03:00
parent 71ed0815cc
commit 18c2892967

View File

@ -46,7 +46,6 @@ todo = '''
https://stackoverflow.com/questions/889333/how-to-check-if-a-file-is-a-valid-image-file
- Enable folder creation in dwguploads or as a separate form
- Register uploaded filenames in the Django db without needing to wait for a reset & bulk file import
'''
@ -200,7 +199,13 @@ def scanupload(request, path=None):
actual_saved = []
if multiple:
for f in multiple:
actual_saved.append( fs.save(f.name, content=f) )
try: # crashes in Django os.chmod call if on WSL, but does save file!
saved_filename = fs.save(f.name, content=f)
except:
print(f'\n !! Permissions failure ?! on attempting to save file {f.name}')
if 'saved_filename' in locals():
if saved_filename.is_file():
actual_saved.append(saved_filename)
# print(f'! - FORM scanupload multiple {actual_saved}')
filesaved = True
@ -367,7 +372,13 @@ def photoupload(request, folder=None):
actual_saved = []
if multiple:
for f in multiple:
actual_saved.append( fs.save(f.name, content=f) )
try: # crashes in Django os.chmod call if on WSL, but does save file!
saved_filename = fs.save(f.name, content=f)
except:
print(f'\n !! Permissions failure ?! on attempting to save file {f.name}')
if 'saved_filename' in locals():
if saved_filename.is_file():
actual_saved.append(saved_filename)
filesaved = True
files = []
dirs = []
@ -456,7 +467,12 @@ def dwgupload(request, folder=None, gitdisable='no'):
if multiple:
for f in multiple:
if dwgvalid(f.name):
try: # crashes in Django os.chmod call if on WSL, but does save file!
saved_filename = fs.save(f.name, content=f)
except:
print(f'\n !! Permissions failure ?! on attempting to save file {f.name}')
if 'saved_filename' in locals():
if saved_filename.is_file():
actual_saved.append(saved_filename)
if gitdisable != 'yes':
dr_add = subprocess.run([git, "add", saved_filename], cwd=dirpath, capture_output=True, text=True)