From 0611fb73e8cfccc86b44db5cd19cf90d151d19d5 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Mon, 2 Oct 2023 09:39:57 +0200 Subject: [PATCH] test removing --- commands/tinfoil.py | 49 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/commands/tinfoil.py b/commands/tinfoil.py index 47968b6..7cea83a 100755 --- a/commands/tinfoil.py +++ b/commands/tinfoil.py @@ -60,18 +60,57 @@ updates = drive_list("nsz/updates") print("Updates OK") -for base in bases: - re_id = re.search(r"\[([0-9A-F]*)\]", base) +def get_title_shortid(name): + re_id = re.search(r"\[([0-9A-F]*)\]", name) if not re_id: continue id = re_id.group(1) - if id not in titles: - continue + return id[0:-4] if id in titles else None - id = id[0:-4] + +def remove(path): + to_remove = [] + + for name in os.listdir(path): + if os.path.isfile(name): + print(name) + id = get_title_shortid(name) + + if not id: + to_remove.append(name) + + if len(to_remove) > 100: + print("Too much to delete, this is the list:") + + for be_removed in to_remove: + print(be_removed) + else: + for be_removed in to_remove: + print(f"Removing {be_removed}") + # os.remove(be_removed) + + +remove("nsz/base") +remove("nsz/dlc") +remove("nsz/updates") + +try: + subprocess.run( + ["rclone", "sync", "-P", "-v", f"{remote}:nsz/homebrew", f"nsz/homebrew/"], + check=True, + stdout=sys.stdout, + ) +except subprocess.CalledProcessError: + pass + +for base in bases: + id = get_title_shortid(base) + + if not id: + continue download("nsz/base", base)