mirror of
https://github.com/restic/restic.git
synced 2025-08-12 17:07:40 +00:00
Examine file ctime when checking if files have changed.
This commit is contained in:
@@ -453,8 +453,13 @@ func fileChanged(fi os.FileInfo, node *restic.Node, ignoreInode bool) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// check size
|
||||
// check status change timestamp
|
||||
extFI := fs.ExtendedStat(fi)
|
||||
if !extFI.ChangeTime.Equal(node.ChangeTime) {
|
||||
return true
|
||||
}
|
||||
|
||||
// check size
|
||||
if uint64(fi.Size()) != node.Size || uint64(extFI.Size) != node.Size {
|
||||
return true
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package archiver
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -576,6 +577,26 @@ func TestFileChanged(t *testing.T) {
|
||||
save(t, filename, defaultContent)
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "new-content-same-timestamp",
|
||||
Modify: func(t testing.TB, filename string) {
|
||||
fi, _ := os.Stat(filename)
|
||||
extFI := fs.ExtendedStat(fi)
|
||||
save(t, filename, bytes.ToUpper(defaultContent))
|
||||
sleep()
|
||||
ts := []syscall.Timespec{
|
||||
{
|
||||
Sec: extFI.AccessTime.Unix(),
|
||||
Nsec: int64(extFI.AccessTime.Nanosecond()),
|
||||
},
|
||||
{
|
||||
Sec: extFI.ModTime.Unix(),
|
||||
Nsec: int64(extFI.ModTime.Nanosecond()),
|
||||
},
|
||||
}
|
||||
syscall.UtimesNano(filename, ts)
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "other-content",
|
||||
Modify: func(t testing.TB, filename string) {
|
||||
|
Reference in New Issue
Block a user