fix(metadata): skip unreadable dirs instead of aborting backup#615
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
filepath.SkipDirfor directories,nilfor files) instead of returning the error and aborting the whole backup.chmod 000subdirectory under the metadata root and verifies the backup still completes and copies sibling files.Why
filepath.Walkininternal/metadata/backup_worker.goreturned the first per-entry error it received, which surfaced asFailed to complete metadata backupin the logs andos.RemoveAll'd the partial backup directory.On Windows this triggers immediately when
library_diris set to a drive root, becauseSystem Volume InformationandWindowsAppsare not readable by the process. The same pattern would break a Linux deployment if any subdirectory underlibrary_dir(ormetadata.root_path) had restrictive permissions. The fix mirrors the tolerant pattern already used ininternal/health/library_sync.go.Fixes #609.
Scope
internal/metadata/backup_worker.go.internal/metadata/backup_worker_test.go(skipped on Windows and when running as root, sincechmod-based denial does not apply there).library_sync.golog noise.Test plan
go test -race -run TestBackupWorker ./internal/metadata/...go vet ./internal/metadata/...go build ./...health.library_dirat a directory containing achmod 000subdir, trigger a metadata backup, confirm the warning is logged andfiles_copied > 0.