backup: exclude irregular files from backup

restic cannot backup irregular files as those don't behave like normal
files. Thus skip them with an error.
This commit is contained in:
Michael Eischer
2024-09-14 18:59:59 +02:00
parent e91a456656
commit f44b7cdf8c
4 changed files with 63 additions and 1 deletions

View File

@@ -46,6 +46,16 @@ func wrapFileInfo(fi os.FileInfo) os.FileInfo {
return res
}
// wrapIrregularFileInfo returns a new os.FileInfo with the mode changed to irregular file
func wrapIrregularFileInfo(fi os.FileInfo) os.FileInfo {
// wrap the os.FileInfo so we can return a modified stat_t
return wrappedFileInfo{
FileInfo: fi,
sys: fi.Sys().(*syscall.Stat_t),
mode: (fi.Mode() &^ os.ModeType) | os.ModeIrregular,
}
}
func statAndSnapshot(t *testing.T, repo archiverRepo, name string) (*restic.Node, *restic.Node) {
fi := lstat(t, name)
want, err := fs.NodeFromFileInfo(name, fi, false)