Skip to content

Commit

Permalink
Merge branch 'add-taplo' of https://github.com/YunoHost/apps into add…
Browse files Browse the repository at this point in the history
…-taplo
  • Loading branch information
OniriCorpe committed Mar 14, 2024
2 parents ca719ad + 77aaf35 commit cecbe9c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tools/app_caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
from git import Repo


APPS_CACHE_DIR = REPO_APPS_ROOT / ".apps_cache"


def app_cache_folder(app: str) -> Path:
return REPO_APPS_ROOT / ".apps_cache" / app
return APPS_CACHE_DIR / app


def app_cache_clone(app: str, infos: dict[str, str]) -> None:
Expand Down Expand Up @@ -84,14 +87,33 @@ def apps_cache_update_all(apps: dict[str, dict[str, Any]], parallel: int = 8) ->
pass


def apps_cache_cleanup(apps: dict[str, dict[str, Any]]) -> None:
for element in APPS_CACHE_DIR.iterdir():
if element.name not in apps.keys():
logging.warning(f"Removing {element}...")
if element.is_dir():
shutil.rmtree(element)
else:
element.unlink()


def __run_for_catalog():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", action="store_true")
parser.add_argument("-j", "--processes", type=int, default=8)
parser.add_argument(
"-c",
"--cleanup",
action="store_true",
default=False,
help="Remove unknown directories from the app cache",
)
args = parser.parse_args()
if args.verbose:
logging.getLogger().setLevel(logging.INFO)

if args.cleanup:
apps_cache_cleanup(get_catalog())
apps_cache_update_all(get_catalog(), parallel=args.processes)


Expand Down

0 comments on commit cecbe9c

Please sign in to comment.