Skip to content

Commit a6bb071

Browse files
committed
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 a6bb071

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

index.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,25 @@ 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+
230+
// Check if mtime before and after hash calculation is matching,
231+
// not sure how bad it is going to be from performace point of
232+
// view, but this is temporary fix as discused in PR 35 here:
233+
// https://github.com/laktak/chkbit/pull/35
234+
if check_mtime != mtime && check_size != size {
235+
// re-calculate the hash for new check_mtime
236+
hash, err = Hashfile(path, algo, i.context.perfMonBytes)
237+
if err != nil {
238+
return nil, err
239+
}
240+
mtime = check_mtime
241+
size = check_size
242+
}
243+
225244
i.context.perfMonFiles(1)
226245
return &idxInfo{
227246
ModTime: mtime,

0 commit comments

Comments
 (0)