Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/cli.py
Show All 24 Lines | CACHE_HOME_DIR: Path = ( | ||||
if "XDG_CACHE_HOME" in os.environ | if "XDG_CACHE_HOME" in os.environ | ||||
else Path.home() / ".cache" | else Path.home() / ".cache" | ||||
) | ) | ||||
DEFAULT_CONFIG: Dict[str, Any] = { | DEFAULT_CONFIG: Dict[str, Any] = { | ||||
"cache": { | "cache": { | ||||
"metadata": {"path": str(CACHE_HOME_DIR / "swh/fuse/metadata.sqlite")}, | "metadata": {"path": str(CACHE_HOME_DIR / "swh/fuse/metadata.sqlite")}, | ||||
"blob": {"path": str(CACHE_HOME_DIR / "swh/fuse/blob.sqlite")}, | "blob": {"path": str(CACHE_HOME_DIR / "swh/fuse/blob.sqlite")}, | ||||
"history": {"path": str(CACHE_HOME_DIR / "swh/fuse/history.sqlite")}, | |||||
"direntry": {"maxram": "10%"}, | "direntry": {"maxram": "10%"}, | ||||
}, | }, | ||||
"web-api": { | "web-api": { | ||||
"url": "https://archive.softwareheritage.org/api/1", | "url": "https://archive.softwareheritage.org/api/1", | ||||
"auth-token": None, | "auth-token": None, | ||||
}, | }, | ||||
"json-indent": 2, | "json-indent": 2, | ||||
} | } | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | def clean(ctx): | ||||
def rm_cache(conf, cache_name): | def rm_cache(conf, cache_name): | ||||
try: | try: | ||||
conf["cache"][cache_name]["path"].unlink(missing_ok=True) | conf["cache"][cache_name]["path"].unlink(missing_ok=True) | ||||
except KeyError: | except KeyError: | ||||
pass | pass | ||||
conf = ctx.obj["config"] | conf = ctx.obj["config"] | ||||
for cache_name in ["blob", "metadata", "history"]: | for cache_name in ["blob", "metadata"]: | ||||
rm_cache(conf, cache_name) | rm_cache(conf, cache_name) |