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)
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():
console.print(f"[red]Error:[/] Path not found: {root}")

View File

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