mirror of
https://github.com/JaCoB1123/dupe-finder.git
synced 2025-05-18 14:11:55 +02:00
Fix file hashing bar being used for images
This commit is contained in:
parent
ecaddb7f73
commit
a2b5d2e224
15
filesmap.go
15
filesmap.go
@ -31,7 +31,7 @@ type FilesMap struct {
|
|||||||
|
|
||||||
incomingBar *mpb.Bar
|
incomingBar *mpb.Bar
|
||||||
|
|
||||||
hashingBar *mpb.Bar
|
fileHashingBar *mpb.Bar
|
||||||
|
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ func (fm *FilesMap) FileHashingWorker(wg *sync.WaitGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hash, err := calculateFileHash(file.path)
|
hash, err := calculateFileHash(file.path)
|
||||||
fm.hashingBar.IncrInt64(file.size)
|
fm.fileHashingBar.IncrInt64(file.size)
|
||||||
fm.FilesHashed <- file
|
fm.FilesHashed <- file
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -75,8 +75,7 @@ func (fm *FilesMap) ImageHashingWorker(wg *sync.WaitGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hash, err := calculateImageHash(file.path)
|
hash, err := calculateImageHash(file.path)
|
||||||
fm.hashingBar.IncrInt64(file.size)
|
//fm.hashingBar.IncrInt64(file.size)
|
||||||
fm.ImagesHashed <- file
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error calculating Hash for image %s: %v\n", file.path, err)
|
log.Printf("Error calculating Hash for image %s: %v\n", file.path, err)
|
||||||
@ -84,7 +83,6 @@ func (fm *FilesMap) ImageHashingWorker(wg *sync.WaitGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
file.imageHash = hash
|
file.imageHash = hash
|
||||||
fm.hashingBar.IncrInt64(file.size)
|
|
||||||
fm.ImagesHashed <- file
|
fm.ImagesHashed <- file
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -127,13 +125,16 @@ func (fm *FilesMap) WalkDirectories() int64 {
|
|||||||
if *minSize > size {
|
if *minSize > size {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
countFiles++
|
countFiles++
|
||||||
|
fm.incomingBar.SetTotal(int64(countFiles), false)
|
||||||
|
|
||||||
fm.hashImage(path, size)
|
fm.hashImage(path, size)
|
||||||
count := fm.hashFile(path, size)
|
count := fm.hashFile(path, size)
|
||||||
|
if count > 0 {
|
||||||
sumSize += size * count
|
sumSize += size * count
|
||||||
fm.incomingBar.SetTotal(int64(countFiles), false)
|
fm.fileHashingBar.SetTotal(int64(sumSize), false)
|
||||||
fm.hashingBar.SetTotal(int64(sumSize), false)
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
2
main.go
2
main.go
@ -60,7 +60,7 @@ func main() {
|
|||||||
decor.CurrentNoUnit("%5d"),
|
decor.CurrentNoUnit("%5d"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
filesMap.hashingBar = filesMap.progress.AddBar(0,
|
filesMap.fileHashingBar = filesMap.progress.AddBar(0,
|
||||||
mpb.PrependDecorators(
|
mpb.PrependDecorators(
|
||||||
decor.Name("Hashing files "),
|
decor.Name("Hashing files "),
|
||||||
decor.Elapsed(decor.ET_STYLE_HHMMSS),
|
decor.Elapsed(decor.ET_STYLE_HHMMSS),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user