chkbit/worker.go

39 lines
813 B
Go
Raw Permalink Normal View History

2024-08-16 23:10:58 +02:00
package chkbit
2024-08-15 23:30:29 +02:00
type WorkItem struct {
path string
filesToIndex []string
dirList []string
2024-08-15 23:30:29 +02:00
ignore *Ignore
}
2024-08-20 16:45:07 +02:00
func (context *Context) runWorker(id int) {
2024-08-15 23:30:29 +02:00
for {
item := <-context.WorkQueue
if item == nil {
break
}
index := newIndex(context, item.path, item.filesToIndex, item.dirList, !context.UpdateIndex)
2024-08-15 23:30:29 +02:00
err := index.load()
if err != nil {
context.log(STATUS_PANIC, index.getIndexFilepath()+": "+err.Error())
}
if context.ShowIgnoredOnly {
index.showIgnoredOnly(item.ignore)
} else {
index.calcHashes(item.ignore)
2024-08-19 22:00:38 +02:00
index.checkFix(context.ForceUpdateDmg)
2024-08-15 23:30:29 +02:00
2024-08-19 22:00:38 +02:00
if context.UpdateIndex {
2024-08-15 23:30:29 +02:00
if changed, err := index.save(); err != nil {
context.logErr(item.path, err)
} else if changed {
context.log(STATUS_UPDATE_INDEX, "")
}
}
}
}
}