EDDNSender: Remove legacy file after migration

This commit is contained in:
Athanasius authored and Athanasius committed 2022-11-22 14:02:09 +00:00
1 parent f3017d40ec
commit 0e20f4bc00
1 file changed
+9 -1
+9 -1
View File
@@ -24,6 +24,7 @@
# ! $# ! $# ! $# ! $# ! $# ! $# ! $# ! $# ! $# ! $# ! $# ! $# ! $# ! $# ! $#
import itertools
import json
import os
import pathlib
import re
import sqlite3
@@ -281,8 +282,8 @@ class EDDNSender:
def convert_legacy_file(self):
"""Convert a legacy file's contents into the sqlite3 db."""
filename = config.app_dir_path / 'replay.jsonl'
try:
filename = config.app_dir_path / 'replay.jsonl'
with open(filename, 'r+', buffering=1) as replay_file:
for line in replay_file:
cmdr, msg = json.loads(line)
@@ -291,6 +292,13 @@ class EDDNSender:
except FileNotFoundError:
pass
finally:
# Best effort at removing the file/contents
# NB: The legacy code assumed it could write to the file.
replay_file = open(filename, 'w') # Will truncate
replay_file.close()
os.unlink(filename)
# TODO: a good few of these methods are static or could be classmethods. they should be created as such.
class EDDN: