Improve handling of moved and added video files (#4598)

* If old file path is not in library, treat as move
* Use existing phash if file with same oshash exists
This commit is contained in:
WithoutPants
2024-02-20 14:04:31 +11:00
committed by GitHub
parent 8b1d4ccc97
commit 76e5598876
4 changed files with 75 additions and 18 deletions

View File

@@ -867,9 +867,11 @@ func (s *scanJob) handleRename(ctx context.Context, f models.File, fp []models.F
continue
}
if _, err := fs.Lstat(other.Base().Path); err != nil {
info, err := fs.Lstat(other.Base().Path)
switch {
case err != nil:
missing = append(missing, other)
} else if strings.EqualFold(f.Base().Path, other.Base().Path) {
case strings.EqualFold(f.Base().Path, other.Base().Path):
// #1426 - if file exists but is a case-insensitive match for the
// original filename, and the filesystem is case-insensitive
// then treat it as a move
@@ -877,6 +879,10 @@ func (s *scanJob) handleRename(ctx context.Context, f models.File, fp []models.F
// treat as a move
missing = append(missing, other)
}
case !s.acceptEntry(ctx, other.Base().Path, info):
// #4393 - if the file is no longer in the configured library paths, treat it as a move
logger.Debugf("File %q no longer in library paths. Treating as a move.", other.Base().Path)
missing = append(missing, other)
}
}