use json instead of python's marshal
This commit is contained in:
parent
6ab3e9657d
commit
cbaa6924c1
@ -1,6 +1,6 @@
|
||||
import os
|
||||
import logging
|
||||
import marshal
|
||||
import json
|
||||
import filelock
|
||||
from contextlib import contextmanager
|
||||
|
||||
@ -20,14 +20,14 @@ class FileDict:
|
||||
data = self.read()
|
||||
yield data
|
||||
write_path = self.path.with_suffix(".tmp")
|
||||
with write_path.open("wb") as f:
|
||||
marshal.dump(data, f)
|
||||
with write_path.open("w") as f:
|
||||
json.dump(data, f)
|
||||
os.rename(write_path, self.path)
|
||||
|
||||
def read(self):
|
||||
try:
|
||||
with self.path.open("rb") as f:
|
||||
return marshal.load(f)
|
||||
with self.path.open("r") as f:
|
||||
return json.load(f)
|
||||
except FileNotFoundError:
|
||||
return {}
|
||||
except Exception:
|
||||
|
@ -35,7 +35,7 @@ class Notifier:
|
||||
self.to_notify_queue = Queue()
|
||||
|
||||
def get_metadata_dict(self, addr):
|
||||
return FileDict(self.vmail_dir / addr / "metadata.marshalled")
|
||||
return FileDict(self.vmail_dir / addr / "metadata.json")
|
||||
|
||||
def add_token(self, addr, token):
|
||||
with self.get_metadata_dict(addr).modify() as data:
|
||||
|
Loading…
Reference in New Issue
Block a user