mirror of
https://github.com/restic/restic.git
synced 2026-10-27 10:48:55 +00:00
archiver: only store deviceID for hardlinks
The deviceID can change e.g. when backing up from filesystem snapshot. It is only used for hardlink detection. Thus there it is not necessary to store it for everything else.
This commit is contained in:
1 parent
63a2350c9e
commit
2ba21fe72b
3 files changed
+8
-1
No files matched your search
@@ -188,6 +188,12 @@ func (arch *Archiver) nodeFromFileInfo(snPath, filename string, fi os.FileInfo)
|
||||
if !arch.WithAtime {
|
||||
node.AccessTime = node.ModTime
|
||||
}
|
||||
if node.Links == 1 || node.Type == "dir" {
|
||||
// the DeviceID is only necessary for hardlinked files
|
||||
// when using subvolumes or snapshots their deviceIDs tend to change which causes
|
||||
// restic to upload new tree blobs
|
||||
node.DeviceID = 0
|
||||
}
|
||||
// overwrite name to match that within the snapshot
|
||||
node.Name = path.Base(snPath)
|
||||
if err != nil {
|
||||
|
||||
@@ -2153,6 +2153,7 @@ func TestMetadataChanged(t *testing.T) {
|
||||
sn, node2 := snapshot(t, repo, fs, nil, "testfile")
|
||||
|
||||
// set some values so we can then compare the nodes
|
||||
want.DeviceID = 0
|
||||
want.Content = node2.Content
|
||||
want.Path = ""
|
||||
if len(want.ExtendedAttributes) == 0 {
|
||||
|
||||
Reference in new issue
Block a user