diff --git a/web/db.py b/web/db.py index 76318fe..60df669 100644 --- a/web/db.py +++ b/web/db.py @@ -4,7 +4,7 @@ import pathlib import time def lock(name): - lockfile = pathlib.Path(f'{name}.lock') + lockfile = pathlib.Path.home() / f'{name}.lock' for i in range(5): try: lockfile.symlink_to('/dev/null') @@ -14,7 +14,7 @@ def lock(name): raise TimeoutError(f'could not lock {name}') def unlock(name): - lockfile = pathlib.Path(f'{name}.lock') + lockfile = pathlib.Path.home() / f'{name}.lock' lockfile.unlink(missing_ok=True) @contextlib.contextmanager @@ -26,12 +26,12 @@ def locked(name): unlock(name) def read(name): - with open(f'{name}.json', 'a+', encoding='utf-8') as f: + with open(pathlib.Path.home() / f'{name}.json', 'a+', encoding='utf-8') as f: f.seek(0) return json.loads(f.read() or '{}') def write(name, data): - with open(f'{name}.json', 'w', encoding='utf-8') as f: + with open(pathlib.Path.home() / f'{name}.json', 'w', encoding='utf-8') as f: json.dump(data, f, indent=2) f.close()