mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
fs/reader: fix open+stat handling
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user