Indexer: Reset file lookup table if count changes #568

This commit is contained in:
Michael Mayer 2020-11-15 13:40:21 +01:00
parent 2bad5b3cdd
commit 068d38820f
2 changed files with 17 additions and 0 deletions

View file

@ -11,6 +11,7 @@ import (
// Files represents a list of already indexed file names and their unix modification timestamps.
type Files struct {
count int
files query.FileMap
mutex sync.RWMutex
}
@ -44,10 +45,24 @@ func (m *Files) Init() error {
return fmt.Errorf("%s (query indexed files)", err.Error())
} else {
m.files = files
m.count = len(files)
return nil
}
}
// Done should be called after all files have been processed.
func (m *Files) Done() {
if (len(m.files) - m.count) == 0 {
return
}
m.mutex.Lock()
defer m.mutex.Unlock()
m.count = 0
m.files = make(query.FileMap)
}
// Ignore tests of a file requires indexing, file name must be relative to the originals path.
func (m *Files) Ignore(fileName, fileRoot string, modTime time.Time, rescan bool) bool {
timestamp := modTime.Unix()

View file

@ -102,6 +102,8 @@ func (ind *Index) Start(opt IndexOptions) fs.Done {
log.Errorf("index: %s", err)
}
defer ind.files.Done()
filesIndexed := 0
ignore := fs.NewIgnoreList(fs.IgnoreFile, true, false)