mirror of
https://github.com/restic/restic.git
synced 2025-07-11 11:48:33 +00:00
fs/reader: fix open+stat handling
This commit is contained in:
parent
19f48084ea
commit
70e1037a49
@ -128,6 +128,9 @@ func (fs *Reader) OpenFile(name string, flag int, _ bool) (f File, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
f = fakeDir{
|
f = fakeDir{
|
||||||
|
fakeFile: fakeFile{
|
||||||
|
fi: item.fi,
|
||||||
|
},
|
||||||
entries: slices.Clone(item.children),
|
entries: slices.Clone(item.children),
|
||||||
}
|
}
|
||||||
return f, nil
|
return f, nil
|
||||||
|
@ -183,28 +183,38 @@ func createDirTest(fpath string, now time.Time) fsTest {
|
|||||||
{
|
{
|
||||||
name: "dir/Open-slash-" + fpath,
|
name: "dir/Open-slash-" + fpath,
|
||||||
f: func(t *testing.T, fs FS) {
|
f: func(t *testing.T, fs FS) {
|
||||||
fi, err := fs.Lstat("/" + fpath)
|
fi := fsStatDir(t, fs, "/"+fpath)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
checkFileInfo(t, fi, "/"+fpath, now, os.ModeDir|0755, true)
|
checkFileInfo(t, fi, "/"+fpath, now, os.ModeDir|0755, true)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "dir/Open-current-" + fpath,
|
name: "dir/Open-current-" + fpath,
|
||||||
f: func(t *testing.T, fs FS) {
|
f: func(t *testing.T, fs FS) {
|
||||||
fi, err := fs.Lstat("./" + fpath)
|
fi := fsStatDir(t, fs, "./"+fpath)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
checkFileInfo(t, fi, "/"+fpath, now, os.ModeDir|0755, true)
|
checkFileInfo(t, fi, "/"+fpath, now, os.ModeDir|0755, true)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fsStatDir(t *testing.T, fs FS, fpath string) *ExtendedFileInfo {
|
||||||
|
f, err := fs.OpenFile(fpath, O_RDONLY, false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fi, err := f.Stat()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = f.Close()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return fi
|
||||||
|
}
|
||||||
|
|
||||||
func TestFSReader(t *testing.T) {
|
func TestFSReader(t *testing.T) {
|
||||||
data := test.Random(55, 1<<18+588)
|
data := test.Random(55, 1<<18+588)
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user