Ensure temp files dont pollute the config dir
Also fix cached values not being de-serialized on python < 3.6
This commit is contained in:
parent
ca0786cd27
commit
334541e8dc
@ -190,7 +190,7 @@ def load_cached_values():
|
|||||||
cached_values.clear()
|
cached_values.clear()
|
||||||
try:
|
try:
|
||||||
with open(cached_path, 'rb') as f:
|
with open(cached_path, 'rb') as f:
|
||||||
cached_values.update(json.loads(f.read()))
|
cached_values.update(json.loads(f.read().decode('utf-8')))
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
@ -205,3 +205,10 @@ def save_cached_values():
|
|||||||
os.rename(p, cached_path)
|
os.rename(p, cached_path)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print('Failed to save cached values with error: {}'.format(err), file=sys.stderr)
|
print('Failed to save cached values with error: {}'.format(err), file=sys.stderr)
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
os.remove(p)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
except Exception as err:
|
||||||
|
print('Failed to delete temp file for saved cached values with error: {}'.format(err), file=sys.stderr)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user