Skip to content

fix(metadata): skip unreadable dirs instead of aborting backup#615

Merged
javi11 merged 1 commit into
mainfrom
fix/metadata-backup-skip-unreadable-dirs
May 24, 2026
Merged

fix(metadata): skip unreadable dirs instead of aborting backup#615
javi11 merged 1 commit into
mainfrom
fix/metadata-backup-skip-unreadable-dirs

Conversation

@javi11
Copy link
Copy Markdown
Owner

@javi11 javi11 commented May 24, 2026

Summary

  • Make the metadata backup walker tolerant of per-entry errors: log a warning and continue (filepath.SkipDir for directories, nil for files) instead of returning the error and aborting the whole backup.
  • Add a regression test that places a chmod 000 subdirectory under the metadata root and verifies the backup still completes and copies sibling files.

Why

filepath.Walk in internal/metadata/backup_worker.go returned the first per-entry error it received, which surfaced as Failed to complete metadata backup in the logs and os.RemoveAll'd the partial backup directory.

On Windows this triggers immediately when library_dir is set to a drive root, because System Volume Information and WindowsApps are not readable by the process. The same pattern would break a Linux deployment if any subdirectory under library_dir (or metadata.root_path) had restrictive permissions. The fix mirrors the tolerant pattern already used in internal/health/library_sync.go.

Fixes #609.

Scope

  • Single behavioral change in internal/metadata/backup_worker.go.
  • New regression test in internal/metadata/backup_worker_test.go (skipped on Windows and when running as root, since chmod-based denial does not apply there).
  • No config, schema, or API changes. Out of scope: optional user-configurable exclusion list and reducing the existing library_sync.go log noise.

Test plan

  • go test -race -run TestBackupWorker ./internal/metadata/...
  • go vet ./internal/metadata/...
  • go build ./...
  • Manual smoke (Linux): point health.library_dir at a directory containing a chmod 000 subdir, trigger a metadata backup, confirm the warning is logged and files_copied > 0.

filepath.Walk would return the first per-entry permission error and
abort the entire metadata backup, surfacing as "Failed to complete
metadata backup" in the logs. On Windows this triggers immediately
when library_dir is a drive root (System Volume Information,
WindowsApps), and on Linux any unreadable subdirectory has the same
effect.

Log a warning and continue: SkipDir for inaccessible directories,
nil for individual files. Context cancellation still aborts.

Fixes #609
@javi11 javi11 merged commit c667235 into main May 24, 2026
2 checks passed
@javi11 javi11 deleted the fix/metadata-backup-skip-unreadable-dirs branch May 24, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Errors when library root is drive root (Windows)

1 participant