Skip to content

Commit

Permalink
feat: Add error handling and logging for inaccessible files
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkobrombin committed Jul 8, 2024
1 parent 9187e7c commit dc68f76
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/processor/dedup.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,23 @@ func (p *DedupProcessor) Process(verbose bool) error {
// Walk the source directory to enqueue jobs
err := filepath.Walk(p.Source, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
if verbose {
log.Printf("Error accessing path %s: %v", path, err)
}
return filepath.SkipDir
}

if !info.IsDir() && path != p.Storage.Opts.Root {
// Check if we have permission to read the file
file, err := os.Open(path)
if err != nil {
if verbose {
log.Printf("Skipping file %s due to permissions: %v", path, err)
}
return nil
}
file.Close()

if verbose {
log.Printf("Adding file to job queue: %s", path)
}
Expand Down

0 comments on commit dc68f76

Please sign in to comment.