Index: Skip redundant thumbs and support symbolic file links #1049 #1874

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2022-07-06 23:01:54 +02:00
parent bbc4f2f276
commit 5ec90a5fff
55 changed files with 1322 additions and 590 deletions

21
pkg/fs/resolve.go Normal file
View File

@@ -0,0 +1,21 @@
package fs
import (
"errors"
"path/filepath"
)
// Resolve returns the absolute file path, with all symlinks resolved.
func Resolve(filePath string) (string, error) {
if filePath == "" {
return "", errors.New("no such file or directory")
}
if target, err := filepath.EvalSymlinks(filePath); err != nil {
return "", errors.New("no such file or directory")
} else if target, err = filepath.Abs(target); target != "" {
return target, err
} else {
return filepath.Abs(filePath)
}
}