Add .cache and build to the skip dir list, make filedust run ONLY in the user home directory

This commit is contained in:
2025-11-29 08:29:14 +00:00
parent 7f2b23b41b
commit c75a5246e3
2 changed files with 15 additions and 2 deletions

View File

@@ -172,6 +172,19 @@ def main(argv: list[str] | None = None) -> int:
args = parser.parse_args(argv) args = parser.parse_args(argv)
root = Path(args.path).expanduser() root = Path(args.path).expanduser()
home = Path.home().resolve()
root_resolved = root.resolve()
# Ensure root is inside the user's home directory
try:
root_resolved.relative_to(home)
except ValueError:
console.print(
f"[red]Error:[/] Refusing to operate outside the user's home directory.\n"
f"Requested: {root_resolved}\n"
f"Allowed: {home}"
)
return 1
if not root.exists(): if not root.exists():
console.print(f"[red]Error:[/] Path not found: {root}") console.print(f"[red]Error:[/] Path not found: {root}")

View File

@@ -23,7 +23,6 @@ JUNK_DIR_NAMES = {
".nox", ".nox",
".tox", ".tox",
".hypothesis", ".hypothesis",
".cache",
".gradle", ".gradle",
".parcel-cache", ".parcel-cache",
".turbo", ".turbo",
@@ -31,7 +30,6 @@ JUNK_DIR_NAMES = {
".vite", ".vite",
".sass-cache", ".sass-cache",
".sass-cache", ".sass-cache",
"build",
"dist", "dist",
} }
@@ -53,6 +51,8 @@ JUNK_FILE_PATTERNS = [
# VCS / system dirs # VCS / system dirs
SKIP_DIR_NAMES = { SKIP_DIR_NAMES = {
".cache",
"build",
".git", ".git",
".hg", ".hg",
".svn", ".svn",