Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/sifty/core/junk.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def _local_appdata() -> Path | None:
return _env_path("LOCALAPPDATA")


def _roaming_appdata() -> Path | None:
return _env_path("APPDATA")


def _browser_cache_roots(local: Path) -> list[Path]:
"""Cache directories across ALL profiles of the installed browsers.

Expand Down Expand Up @@ -60,6 +64,29 @@ def _browser_cache_roots(local: Path) -> list[Path]:
if cand.is_dir():
roots.append(cand)

# Opera and Opera GX store their User Data under %APPDATA% (roaming), not %LOCALAPPDATA%.
appdata = _roaming_appdata()
if appdata:
opera_user_data = [
appdata / "Opera Software" / "Opera Stable",
appdata / "Opera Software" / "Opera GX Stable",
]
for user_data in opera_user_data:
if not user_data.is_dir():
continue
try:
profiles = [
p for p in user_data.iterdir()
if p.is_dir() and (p.name == "Default" or p.name.startswith("Profile"))
]
except OSError:
continue
for profile in profiles:
for sub in ("Cache", "Code Cache", "GPUCache"):
cand = profile / sub
if cand.is_dir():
roots.append(cand)

firefox_profiles = local / "Mozilla" / "Firefox" / "Profiles"
if firefox_profiles.is_dir():
try:
Expand Down Expand Up @@ -108,7 +135,7 @@ def junk_categories(config=None) -> list[JunkCategory]:
cats.append(
JunkCategory(
"browser-cache", "Browser caches",
"On-disk caches for every Chrome/Edge/Brave/Vivaldi profile and "
"On-disk caches for every Chrome/Edge/Brave/Vivaldi/Opera profile and "
"Firefox (never cookies, history, or passwords).",
_browser_cache_roots(local),
)
Expand Down
Loading