Don't try to save if filename too long

main
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:
json_file.write(json.dumps(json_object))
return True
except OSError as ex:
except OSError as exc:
print('EX: save_json ' + str(tries) + ' ' + str(filename) +
' ' + str(ex))
' ' + str(exc))
if exc.errno == 36:
# filename too long
break
time.sleep(1)
tries += 1
return False