Don't try to save if filename too long

merge-requests/30/head
Bob Mottram 2024-04-10 18:05:44 +01:00
parent ccc4759b10
commit edd6298fa7
1 changed files with 5 additions and 2 deletions

View File

@ -1215,9 +1215,12 @@ def save_json(json_object: {}, filename: str) -> bool:
with open(filename, 'w+', encoding='utf-8') as json_file: with open(filename, 'w+', encoding='utf-8') as json_file:
json_file.write(json.dumps(json_object)) json_file.write(json.dumps(json_object))
return True return True
except OSError as ex: except OSError as exc:
print('EX: save_json ' + str(tries) + ' ' + str(filename) + print('EX: save_json ' + str(tries) + ' ' + str(filename) +
' ' + str(ex)) ' ' + str(exc))
if exc.errno == 36:
# filename too long
break
time.sleep(1) time.sleep(1)
tries += 1 tries += 1
return False return False