Import: Refactor indexing of related original filenames #2623
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
90567072cd
commit
0cb9cbc56a
|
@ -23,7 +23,6 @@ type ImportJob struct {
|
|||
func ImportWorker(jobs <-chan ImportJob) {
|
||||
for job := range jobs {
|
||||
var destMainFileName string
|
||||
relatedOriginalNames := make(map[string]string)
|
||||
|
||||
o := job.IndexOpt
|
||||
imp := job.Imp
|
||||
|
@ -31,6 +30,9 @@ func ImportWorker(jobs <-chan ImportJob) {
|
|||
impPath := job.ImportOpt.Path
|
||||
related := job.Related
|
||||
|
||||
// relatedOriginalNames contains the original filenames of related files.
|
||||
relatedOriginalNames := make(map[string]string, len(related.Files))
|
||||
|
||||
if related.Main == nil {
|
||||
log.Warnf("import: %s belongs to no supported media file", clean.Log(fs.RelName(job.FileName, impPath)))
|
||||
continue
|
||||
|
@ -61,7 +63,7 @@ func ImportWorker(jobs <-chan ImportJob) {
|
|||
if destFileName, err := imp.DestinationFilename(related.Main, f); err == nil {
|
||||
destDir := filepath.Dir(destFileName)
|
||||
|
||||
// Keep original name of related files after they are renamed, so they are indexed with the original name.
|
||||
// Remember the original filenames of related files, so they can later be indexed and searched.
|
||||
relatedOriginalNames[destFileName] = relFileName
|
||||
|
||||
if fs.PathExists(destDir) {
|
||||
|
@ -235,7 +237,7 @@ func ImportWorker(jobs <-chan ImportJob) {
|
|||
}
|
||||
}
|
||||
|
||||
// Index related MediaFile.
|
||||
// Index related media file including its original filename.
|
||||
res := ind.MediaFile(f, o, relatedOriginalNames[f.FileName()], photoUID)
|
||||
|
||||
// Save file error.
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package photoprism
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/classify"
|
||||
"github.com/photoprism/photoprism/internal/config"
|
||||
"github.com/photoprism/photoprism/internal/entity"
|
||||
"github.com/photoprism/photoprism/internal/face"
|
||||
"github.com/photoprism/photoprism/internal/nsfw"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestImportWorker_OriginalFileNames(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue