Remove dead migration code that was fucking me over

This commit is contained in:
Reid 'arrdem' McKenzie 2022-11-26 23:08:13 -07:00
parent ca10da03b3
commit 7b65a10bd8

View file

@ -45,54 +45,22 @@ class RelayDatabase(dict):
self["private-key"] = self.PRIVKEY.exportKey("PEM").decode("utf-8")
def load(self):
new_db = True
with self.config.db.open() as fd:
data = json.load(fd)
try:
with self.config.db.open() as fd:
data = json.load(fd)
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
self["version"] = data.get("version", 1)
self["private-key"] = data.get("private-key")
self["relay-list"] = data.get("relay-list", {})
self["follow-requests"] = data.get("follow-requests")
if not self.privkey:
logging.info("No actor keys present, generating 4096-bit RSA keypair.")
self.generate_key()
self.save()
else:
self.PRIVKEY = RSA.importKey(self.privkey)
self.save()
return not new_db
def save(self):
with self.config.db.open("w") as fd:
json.dump(self, fd, indent=4)