mirror of
https://github.com/restic/restic.git
synced 2024-12-21 23:33:03 +00:00
archiver: properly create node for vss backups
Previously, NodeFromFileInfo used the original file path to create the node, which also meant that extended metadata was read from there instead of within the vss snapshot. This change is a temporary solution for restic 0.17.2 and will be replaced with a clean fix in restic 0.18.0.
This commit is contained in:
parent
9553d873ff
commit
4df2e33568
5 changed files with 21 additions and 1 deletions
|
@ -248,7 +248,8 @@ func (arch *Archiver) trackItem(item string, previous, current *restic.Node, s I
|
|||
|
||||
// nodeFromFileInfo returns the restic node from an os.FileInfo.
|
||||
func (arch *Archiver) nodeFromFileInfo(snPath, filename string, fi os.FileInfo, ignoreXattrListError bool) (*restic.Node, error) {
|
||||
node, err := restic.NodeFromFileInfo(filename, fi, ignoreXattrListError)
|
||||
mappedFilename := arch.FS.MapFilename(filename)
|
||||
node, err := restic.NodeFromFileInfo(mappedFilename, fi, ignoreXattrListError)
|
||||
if !arch.WithAtime {
|
||||
node.AccessTime = node.ModTime
|
||||
}
|
||||
|
|
|
@ -18,6 +18,12 @@ func (fs Local) VolumeName(path string) string {
|
|||
return filepath.VolumeName(path)
|
||||
}
|
||||
|
||||
// MapFilename is a temporary hack to prepare a filename for usage with
|
||||
// NodeFromFileInfo. This is only relevant for LocalVss.
|
||||
func (fs Local) MapFilename(filename string) string {
|
||||
return filename
|
||||
}
|
||||
|
||||
// Open opens a file for reading.
|
||||
func (fs Local) Open(name string) (File, error) {
|
||||
f, err := os.Open(fixpath(name))
|
||||
|
|
|
@ -145,6 +145,12 @@ func (fs *LocalVss) Lstat(name string) (os.FileInfo, error) {
|
|||
return os.Lstat(fs.snapshotPath(name))
|
||||
}
|
||||
|
||||
// MapFilename is a temporary hack to prepare a filename for usage with
|
||||
// NodeFromFileInfo. This is only relevant for LocalVss.
|
||||
func (fs *LocalVss) MapFilename(filename string) string {
|
||||
return fs.snapshotPath(filename)
|
||||
}
|
||||
|
||||
// isMountPointIncluded is true if given mountpoint included by user.
|
||||
func (fs *LocalVss) isMountPointIncluded(mountPoint string) bool {
|
||||
if fs.excludeVolumes == nil {
|
||||
|
|
|
@ -39,6 +39,12 @@ func (fs *Reader) VolumeName(_ string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
// MapFilename is a temporary hack to prepare a filename for usage with
|
||||
// NodeFromFileInfo. This is only relevant for LocalVss.
|
||||
func (fs *Reader) MapFilename(filename string) string {
|
||||
return filename
|
||||
}
|
||||
|
||||
// Open opens a file for reading.
|
||||
func (fs *Reader) Open(name string) (f File, err error) {
|
||||
switch name {
|
||||
|
|
|
@ -11,6 +11,7 @@ type FS interface {
|
|||
OpenFile(name string, flag int, perm os.FileMode) (File, error)
|
||||
Stat(name string) (os.FileInfo, error)
|
||||
Lstat(name string) (os.FileInfo, error)
|
||||
MapFilename(filename string) string
|
||||
|
||||
Join(elem ...string) string
|
||||
Separator() string
|
||||
|
|
Loading…
Reference in a new issue