mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 20:49:02 +00:00
Treat symlinks to directories like directories
This allows symlinking to create additional subalbums. Closes: #431
This commit is contained in:
@@ -181,7 +181,13 @@ func findMediaForAlbum(album *models.Album, cache *scanner_cache.AlbumScannerCac
|
||||
for _, item := range dirContent {
|
||||
photoPath := path.Join(album.Path, item.Name())
|
||||
|
||||
if !item.IsDir() && cache.IsPathMedia(photoPath) {
|
||||
isDirSymlink, err := utils.IsDirSymlink(photoPath)
|
||||
if err != nil {
|
||||
log.Printf("Cannot detect whether %s is symlink to a directory. Pretending it is not", photoPath)
|
||||
isDirSymlink = false
|
||||
}
|
||||
|
||||
if !item.IsDir() && !isDirSymlink && cache.IsPathMedia(photoPath) {
|
||||
// Match file against ignore data
|
||||
if albumIgnore.MatchesPath(item.Name()) {
|
||||
log.Printf("File %s ignored\n", item.Name())
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/photoview/photoview/api/graphql/models"
|
||||
"github.com/photoview/photoview/api/scanner/scanner_cache"
|
||||
"github.com/photoview/photoview/api/scanner/scanner_utils"
|
||||
"github.com/photoview/photoview/api/utils"
|
||||
"github.com/pkg/errors"
|
||||
ignore "github.com/sabhiram/go-gitignore"
|
||||
"gorm.io/gorm"
|
||||
@@ -198,7 +199,13 @@ func findAlbumsForUser(db *gorm.DB, user *models.User, album_cache *scanner_cach
|
||||
continue
|
||||
}
|
||||
|
||||
if item.IsDir() && directoryContainsPhotos(subalbumPath, album_cache, albumIgnore) {
|
||||
isDirSymlink, err := utils.IsDirSymlink(subalbumPath)
|
||||
if err != nil {
|
||||
scanErrors = append(scanErrors, errors.Wrapf(err, "could not check for symlink target of %s", subalbumPath))
|
||||
continue
|
||||
}
|
||||
|
||||
if (item.IsDir() || isDirSymlink) && directoryContainsPhotos(subalbumPath, album_cache, albumIgnore) {
|
||||
scanQueue.PushBack(scanInfo{
|
||||
path: subalbumPath,
|
||||
parent: album,
|
||||
|
||||
Reference in New Issue
Block a user