Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2025-11-14 22:13:55 -05:00
parent edac6281df
commit 1dbeda88aa
3 changed files with 4 additions and 22 deletions

View File

@ -52,16 +52,6 @@ var _ = Describe("folder_entry", func() {
Expect(entry.updTime).To(Equal(updateInfo.UpdatedAt))
Expect(entry.prevHash).To(Equal(updateInfo.Hash))
})
It("creates a new folder entry with zero time when no previous update exists", func() {
folderID := model.FolderID(lib, path)
emptyInfo := model.FolderUpdateInfo{}
entry := newFolderEntry(job, folderID, path, emptyInfo.UpdatedAt, emptyInfo.Hash)
Expect(entry.updTime).To(BeZero())
Expect(entry.prevHash).To(BeEmpty())
})
})
Describe("createFolderEntry", func() {

View File

@ -96,6 +96,9 @@ func (j *scanJob) popLastUpdate(folderID string) model.FolderUpdateInfo {
return lastUpdate
}
// createFolderEntry creates a new folderEntry for the given path, using the last update info from the job
// to populate the previous update time and hash. It also removes the folder from the job's lastUpdates map.
// This is used to track which folders have been found during the walk_dir_tree.
func (j *scanJob) createFolderEntry(path string) *folderEntry {
id := model.FolderID(j.lib, path)
info := j.popLastUpdate(id)
@ -141,15 +144,7 @@ func (p *phaseFolders) producer() ppl.Producer[*folderEntry] {
break
}
var outputChan <-chan *folderEntry
var err error
// Use selective folder loading if target folders are specified
if len(job.targetFolders) > 0 {
log.Debug(p.ctx, "Scanner: Loading specific folders and all their subdirectories (recursive)", "lib", job.lib.Name, "numTargets", len(job.targetFolders))
}
outputChan, err = walkDirTree(p.ctx, job, job.targetFolders...)
outputChan, err := walkDirTree(p.ctx, job, job.targetFolders...)
if err != nil {
log.Warn(p.ctx, "Scanner: Error scanning library", "lib", job.lib.Name, err)
}

View File

@ -87,9 +87,6 @@ var _ = Describe("ScanFolders", Ordered, func() {
"pop/track6.mp3": pop(track(1, "Pop Track 1")),
})
// Use the existing library from BeforeEach
// (lib is already created with the path "fake:///music")
// Scan only the "rock" and "jazz" folders (including their subdirectories)
targets := []model.ScanTarget{
{LibraryID: lib.ID, FolderPath: "rock"},