mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-18 18:07:37 +03:00
EDDNSender: Remove legacy file after migration
This commit is contained in:
parent
f3017d40ec
commit
0e20f4bc00
@ -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."""
|
||||
try:
|
||||
filename = config.app_dir_path / 'replay.jsonl'
|
||||
try:
|
||||
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user