flatten callbackPost logic

This commit is contained in:
sentriz
2019-07-25 15:38:56 +01:00
parent 5ffa33ac7e
commit d02ace460d

View File

@@ -212,22 +212,25 @@ func (s *Scanner) callbackItem(fullPath string, info *godirwalk.Dirent) error {
} }
func (s *Scanner) callbackPost(fullPath string, info *godirwalk.Dirent) error { func (s *Scanner) callbackPost(fullPath string, info *godirwalk.Dirent) error {
defer func() {
s.curCover = ""
}()
if s.trTxOpen { if s.trTxOpen {
s.trTx.Commit() s.trTx.Commit()
s.trTxOpen = false s.trTxOpen = false
} }
// begin taking the current folder if the stack and add it's // begin taking the current folder off the stack and add it's
// parent, cover that we found, etc. // parent, cover that we found, etc.
folder := s.curFolders.Pop() folder := s.curFolders.Pop()
if folder.ReceivedPaths { if !folder.ReceivedPaths {
folder.ParentID = s.curFolders.PeekID() return nil
folder.Cover = s.curCover
s.db.Save(folder)
// we only log changed folders
log.Printf("processed folder `%s`\n",
path.Join(folder.LeftPath, folder.RightPath))
} }
s.curCover = "" folder.ParentID = s.curFolders.PeekID()
folder.Cover = s.curCover
s.db.Save(folder)
// we only log changed folders
log.Printf("processed folder `%s`\n",
path.Join(folder.LeftPath, folder.RightPath))
return nil return nil
} }