diff --git a/plugins/eddn.py b/plugins/eddn.py index 9bfab900..39ecf147 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -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."""