feat: version update logic

This commit is contained in:
aclist committed 2026-05-09 22:46:41 +09:00
1 parent 6e320763c9
commit 1268c388b0
4 files changed
+43 -8

No files matched your search

+27
View File
@@ -173,3 +173,30 @@ def get_mod_dir_size(path: Path) -> int:
elif i.is_dir():
size += get_mod_dir_size(i)
return size
def version_file_to_dict(file: Path) -> dict[str, str]:
versions = file.read_text().splitlines()
d: dict[str, str] = {}
for version in versions:
line = version.split(",")
mod = line[0]
stamp = line[1]
d[mod] = stamp
return d
def update_signatures(
mods: list[tuple[str, str, int, int]], version_file: Path
) -> None:
d = version_file_to_dict(version_file)
for _title, mod, stamp, size in mods:
d[mod] = str(stamp)
versions: list[str] = []
for k, v in d.items():
row = ",".join([k, v])
versions.append(row)
with open(version_file, "w") as f:
for version in versions:
f.write(f"{version}\n")