fs: rewrite Reader to build fs tree up front

This adds proper support for filenames that include directories. For
example, `/foo/bar` would result in an error when trying to open `/foo`.

The directory tree is now build upfront. This ensures let's the
directory tree construction be handled only once. All accessors then
only have to look up the constructed directory entries.
This commit is contained in:
Michael Eischer committed 2025-04-11 21:37:40 +02:00
1 parent 3d14e92905
commit 3a995172b7
5 files changed
+177 -117

No files matched your search

+4 -6
View File
@@ -591,12 +591,10 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
return err
}
}
targetFS = &fs.Reader{
ModTime: timeStamp,
Name: filename,
Mode: 0644,
ReadCloser: source,
}
targetFS = fs.NewReader(filename, source, fs.ReaderOptions{
ModTime: timeStamp,
Mode: 0644,
})
targets = []string{filename}
}