[#2375] Improve Legacy Queue Detection

This commit is contained in:
David Sangrey committed 2025-05-19 22:00:17 -04:00
1 parent faac1291fb
commit d6fb5d7477
1 file changed
+12 -10
+12 -10
View File
@@ -223,22 +223,24 @@ class EDDNSender:
def convert_legacy_file(self):
"""Convert a legacy file's contents into the sqlite3 db."""
# DEPRECATED: Legacy files no longer used as of 5.6.0. Will remove in 6.0 or later.
filename = config.app_dir_path / 'replay.jsonl'
if not filename.exists():
return
logger.info("Converting legacy `replay.jsonl` to `eddn_queue-v1.db`")
try:
with open(filename, 'r+', buffering=1) as replay_file:
logger.info("Converting legacy `replay.jsonl` to `eddn_queue-v1.db`")
with filename.open('r', encoding='utf-8') as replay_file:
for line in replay_file:
cmdr, msg = json.loads(line)
self.add_message(cmdr, msg)
except FileNotFoundError:
except Exception as e:
logger.exception("Failed to convert legacy file: %s", e)
return
logger.info("Conversion to `eddn_queue-v1.db` complete, removing `replay.jsonl`")
# Best effort at removing the file/contents
with open(filename, 'w') as replay_file:
replay_file.truncate()
os.unlink(filename)
logger.info("Conversion complete, removing `replay.jsonl`")
try:
filename.unlink()
except Exception as e:
logger.warning("Could not delete legacy file: %s", e)
def close(self) -> None:
"""Clean up any resources."""