mirror of
https://github.com/restic/restic.git
synced 2025-07-11 03:48:34 +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{
|
||||
fakeFile: fakeFile{
|
||||
fi: item.fi,
|
||||
},
|
||||
entries: slices.Clone(item.children),
|
||||
}
|
||||
return f, nil
|
||||
|
@ -183,28 +183,38 @@ func createDirTest(fpath string, now time.Time) fsTest {
|
||||
{
|
||||
name: "dir/Open-slash-" + fpath,
|
||||
f: func(t *testing.T, fs FS) {
|
||||
fi, err := fs.Lstat("/" + fpath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fi := fsStatDir(t, fs, "/"+fpath)
|
||||
checkFileInfo(t, fi, "/"+fpath, now, os.ModeDir|0755, true)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "dir/Open-current-" + fpath,
|
||||
f: func(t *testing.T, fs FS) {
|
||||
fi, err := fs.Lstat("./" + fpath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fi := fsStatDir(t, fs, "./"+fpath)
|
||||
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) {
|
||||
data := test.Random(55, 1<<18+588)
|
||||
now := time.Now()
|
||||
|
Loading…
x
Reference in New Issue
Block a user