Remove dead migration code that was fucking me over
This commit is contained in:
parent
ca10da03b3
commit
7b65a10bd8
1 changed files with 7 additions and 39 deletions
|
@ -45,54 +45,22 @@ class RelayDatabase(dict):
|
||||||
self["private-key"] = self.PRIVKEY.exportKey("PEM").decode("utf-8")
|
self["private-key"] = self.PRIVKEY.exportKey("PEM").decode("utf-8")
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
new_db = True
|
with self.config.db.open() as fd:
|
||||||
|
data = json.load(fd)
|
||||||
|
|
||||||
try:
|
self["version"] = data.get("version", 1)
|
||||||
with self.config.db.open() as fd:
|
self["private-key"] = data.get("private-key")
|
||||||
data = json.load(fd)
|
self["relay-list"] = data.get("relay-list", {})
|
||||||
|
self["follow-requests"] = data.get("follow-requests")
|
||||||
self["version"] = data.get("version", None)
|
|
||||||
self["private-key"] = data.get("private-key")
|
|
||||||
|
|
||||||
if self["version"] == None:
|
|
||||||
self["version"] = 1
|
|
||||||
|
|
||||||
if "actorKeys" in data:
|
|
||||||
self["private-key"] = data["actorKeys"]["privateKey"]
|
|
||||||
|
|
||||||
for item in data.get("relay-list", []):
|
|
||||||
domain = urlparse(item).hostname
|
|
||||||
self["relay-list"][domain] = {"inbox": item, "followid": None}
|
|
||||||
|
|
||||||
else:
|
|
||||||
self["relay-list"] = data.get("relay-list", {})
|
|
||||||
|
|
||||||
for domain in self["relay-list"].keys():
|
|
||||||
if self.config.is_banned(domain) or (
|
|
||||||
self.config.whitelist_enabled
|
|
||||||
and not self.config.is_whitelisted(domain)
|
|
||||||
):
|
|
||||||
self.del_inbox(domain)
|
|
||||||
|
|
||||||
new_db = False
|
|
||||||
|
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
except json.decoder.JSONDecodeError as e:
|
|
||||||
if self.config.db.stat().st_size > 0:
|
|
||||||
raise e from None
|
|
||||||
|
|
||||||
if not self.privkey:
|
if not self.privkey:
|
||||||
logging.info("No actor keys present, generating 4096-bit RSA keypair.")
|
logging.info("No actor keys present, generating 4096-bit RSA keypair.")
|
||||||
self.generate_key()
|
self.generate_key()
|
||||||
|
self.save()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.PRIVKEY = RSA.importKey(self.privkey)
|
self.PRIVKEY = RSA.importKey(self.privkey)
|
||||||
|
|
||||||
self.save()
|
|
||||||
return not new_db
|
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
with self.config.db.open("w") as fd:
|
with self.config.db.open("w") as fd:
|
||||||
json.dump(self, fd, indent=4)
|
json.dump(self, fd, indent=4)
|
||||||
|
|
Loading…
Reference in a new issue