archiver: improve error message for irregular files

Since Go 1.21, most reparse points are considered as irregular files.
Depending on the underlying driver these can exhibit nearly arbitrary
behavior. When encountering such a file, restic returned an
indecipherable error message: `error: invalid node type ""`.

Add the filepath to the error message and state that the file type is
not supported.
This commit is contained in:
Michael Eischer committed 2024-01-08 21:33:05 +01:00
1 parent c95de54726
commit e886c3f6b2
2 files changed
+8 -2

No files matched your search

+5 -1
View File
@@ -2,6 +2,7 @@ package archiver
import (
"context"
"fmt"
"os"
"path"
"runtime"
@@ -183,7 +184,10 @@ func (arch *Archiver) nodeFromFileInfo(snPath, filename string, fi os.FileInfo)
}
// overwrite name to match that within the snapshot
node.Name = path.Base(snPath)
return node, errors.WithStack(err)
if err != nil {
return node, fmt.Errorf("nodeFromFileInfo %v: %w", filename, err)
}
return node, err
}
// loadSubtree tries to load the subtree referenced by node. In case of an error, nil is returned.