From 65c39673845de4ab43b5eb3fc74974ed803a5d21 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sun, 23 May 2021 13:49:07 +0200 Subject: [PATCH] Import: Never remove ignored directories #1319 --- internal/photoprism/import.go | 14 ++++++-------- internal/photoprism/import_options.go | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/internal/photoprism/import.go b/internal/photoprism/import.go index 7d540efe2..784da5aa6 100644 --- a/internal/photoprism/import.go +++ b/internal/photoprism/import.go @@ -129,14 +129,12 @@ func (imp *Import) Start(opt ImportOptions) fs.Done { isDir := info.IsDir() isSymlink := info.IsSymlink() - if isDir { - if fileName != importPath { - directories = append(directories, fileName) - } - } - if skip, result := fs.SkipWalk(fileName, isDir, isSymlink, done, ignore); skip { if isDir && result != filepath.SkipDir { + if fileName != importPath { + directories = append(directories, fileName) + } + folder := entity.NewFolder(entity.RootImport, fs.RelName(fileName, imp.conf.ImportPath()), fs.BirthTime(fileName)) if err := folder.Create(); err == nil { @@ -210,7 +208,7 @@ func (imp *Import) Start(opt ImportOptions) fs.Done { }) if opt.RemoveEmptyDirectories { - // Remove empty directories from import path + // Remove empty directories from import path. for _, directory := range directories { if fs.IsEmpty(directory) { if err := os.Remove(directory); err != nil { @@ -223,7 +221,7 @@ func (imp *Import) Start(opt ImportOptions) fs.Done { } if opt.RemoveDotFiles { - // Remove hidden .files if option is enabled + // Remove hidden .files if option is enabled. for _, file := range ignore.Hidden() { if !fs.FileExists(file) { continue diff --git a/internal/photoprism/import_options.go b/internal/photoprism/import_options.go index 1602d1ee8..90951777a 100644 --- a/internal/photoprism/import_options.go +++ b/internal/photoprism/import_options.go @@ -22,7 +22,7 @@ func ImportOptionsCopy(path string) ImportOptions { return result } -// IndexOptionsMove returns import options for moving files to originals (modifies import directory). +// ImportOptionsMove returns import options for moving files to originals (modifies import directory). func ImportOptionsMove(path string) ImportOptions { result := ImportOptions{ Path: path,