mirror of
https://github.com/aclist/dztui.git
synced 2026-08-28 10:47:15 +02:00
chore: update file migration logic
This commit is contained in:
parent
0a6bd831bd
commit
446d4db290
@ -5,6 +5,7 @@ from dataclasses import dataclass
|
||||
|
||||
from dzgui.const.constants import APP_NAME_LOWER, DEBUG_LOG, SYSTEM_LOG
|
||||
|
||||
|
||||
@dataclass
|
||||
class Xdg:
|
||||
config: Path
|
||||
@ -73,7 +74,7 @@ def parse_filepaths(xdg: dict) -> Xdg:
|
||||
system = state / "logs" / SYSTEM_LOG
|
||||
debug = state / "logs" / DEBUG_LOG
|
||||
|
||||
columns = state / "dzg.cols.json"
|
||||
columns = state / "dzg.columns.json"
|
||||
notes = state / "dzg.notes.json"
|
||||
resolution = state / "dzg.res.json"
|
||||
history = state / "dzg.history"
|
||||
|
||||
@ -18,6 +18,7 @@ def has_new_config(config: Path) -> bool:
|
||||
|
||||
|
||||
def migrate_cols_file(res: Path) -> None:
|
||||
# NOTE: dzg.columns.json is API 7 spec
|
||||
old_res = Path.home() / LEGACY_COLS_PATH
|
||||
if old_res.is_file():
|
||||
j = read_json(old_res)
|
||||
@ -32,11 +33,20 @@ def migrate_cols_file(res: Path) -> None:
|
||||
def copy_state_files(state_path: Path) -> None:
|
||||
home = Path.home()
|
||||
legacy = home / ".local/state/dzgui"
|
||||
to_copy = [
|
||||
"dzg.res.json",
|
||||
"dzg.notes.json",
|
||||
"dzg.history",
|
||||
"dzg.versions",
|
||||
"ips.csv",
|
||||
".month",
|
||||
]
|
||||
if state_path == legacy:
|
||||
# TODO: log this
|
||||
return
|
||||
for file in legacy.iterdir():
|
||||
shutil.copy(file, state_path / file.name)
|
||||
if file.name in to_copy:
|
||||
shutil.copy(file, state_path / file.name)
|
||||
|
||||
|
||||
def copy_ipdb(ips_path: Path) -> None:
|
||||
|
||||
@ -18,8 +18,8 @@ from dzgui.init.dayz import is_dayz_installed
|
||||
from dzgui.init.flock import lock_acquire
|
||||
from dzgui.init.migrate import (
|
||||
has_new_config,
|
||||
# migrate_cols_file,
|
||||
# copy_state_files,
|
||||
copy_state_files,
|
||||
migrate_cols_file,
|
||||
)
|
||||
from dzgui.init.prefix import get_version
|
||||
from dzgui.init.prereqs import has_steam_client
|
||||
@ -96,7 +96,6 @@ def main() -> None:
|
||||
if XDG.resolution.parent.is_dir() is False:
|
||||
make_parents(XDG.resolution)
|
||||
|
||||
# TODO: test
|
||||
if XDG.debug.is_file() is False:
|
||||
make_parents(XDG.debug)
|
||||
|
||||
@ -107,10 +106,9 @@ def main() -> None:
|
||||
del os.environ["GTK_IM_MODULE"]
|
||||
|
||||
if has_new_config(XDG.config) is False:
|
||||
migrate_cols_file(XDG.columns)
|
||||
copy_state_files(xdg_paths["XDG_STATE_HOME"])
|
||||
# TODO: add logging inside wizard
|
||||
# TODO: copy notes file, version file, etc.
|
||||
# migrate_cols_file(XDG.columns)
|
||||
# copy_state_files(xdg_paths["XDG_STATE_HOME"])
|
||||
SetupWizard(version, _is_steam_deck, XDG.config)
|
||||
return
|
||||
|
||||
@ -147,6 +145,5 @@ def main() -> None:
|
||||
update_available=update_available,
|
||||
use_miles=use_miles,
|
||||
)
|
||||
# TODO: drop allow updates
|
||||
print(boot.all_ok)
|
||||
App(prefs)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user