Skip to content

Commit d17398a

Browse files
authored
Fix: Check if mtime before and after hash calculation match.
Check if mtime before and after hash calculation is matching, not sure how bad it is going to be from performace point of view, but this is temporary fix as discused in PR 35 here: laktak#35
1 parent e3fc33f commit d17398a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

index.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,23 @@ func (i *Index) calcFile(name string, algo string) (*idxInfo, error) {
222222
if err != nil {
223223
return nil, err
224224
}
225+
check_mtime, check_size, err := getMtS(path)
226+
if err != nil {
227+
return nil, err
228+
}
229+
// Check if mtime before and after hash calculation is matching,
230+
// not sure how bad it is going to be from performace point of
231+
// view, but this is temporary fix as discused in PR 35 here:
232+
// https://github.com/laktak/chkbit/pull/35
233+
if check_mtime != mtime && check_size != size {
234+
// re-calculate the hash for new check_mtime
235+
hash, err := Hashfile(path, algo, i.context.perfMonBytes)
236+
if err != nil {
237+
return nil, err
238+
}
239+
mtime = check_mtime
240+
size = check_size
241+
}
225242
i.context.perfMonFiles(1)
226243
return &idxInfo{
227244
ModTime: mtime,

0 commit comments

Comments
 (0)