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