fs: remove Stat from FS interface

This commit is contained in:
Michael Eischer
2024-11-02 18:09:39 +01:00
parent 623ba92b98
commit 2f2ce9add2
6 changed files with 37 additions and 51 deletions

View File

@@ -34,12 +34,6 @@ func (fs Local) OpenFile(name string, flag int) (File, error) {
return f, nil
}
// Stat returns a FileInfo describing the named file. If there is an error, it
// will be of type *PathError.
func (fs Local) Stat(name string) (os.FileInfo, error) {
return os.Stat(fixpath(name))
}
// Lstat returns the FileInfo structure describing the named file.
// If the file is a symbolic link, the returned FileInfo
// describes the symbolic link. Lstat makes no attempt to follow the link.

View File

@@ -131,11 +131,6 @@ func (fs *LocalVss) OpenFile(name string, flag int) (File, error) {
return fs.FS.OpenFile(fs.snapshotPath(name), flag)
}
// Stat wraps the Stat method of the underlying file system.
func (fs *LocalVss) Stat(name string) (os.FileInfo, error) {
return fs.FS.Stat(fs.snapshotPath(name))
}
// Lstat wraps the Lstat method of the underlying file system.
func (fs *LocalVss) Lstat(name string) (os.FileInfo, error) {
return fs.FS.Lstat(fs.snapshotPath(name))

View File

@@ -317,16 +317,12 @@ func TestVSSFS(t *testing.T) {
// trigger snapshot creation and
// capture FI while file still exists (should already be within the snapshot)
origFi, err := localVss.Stat(tempfile)
origFi, err := localVss.Lstat(tempfile)
rtest.OK(t, err)
// remove original file
rtest.OK(t, os.Remove(tempfile))
statFi, err := localVss.Stat(tempfile)
rtest.OK(t, err)
rtest.Equals(t, origFi.Mode(), statFi.Mode())
lstatFi, err := localVss.Lstat(tempfile)
rtest.OK(t, err)
rtest.Equals(t, origFi.Mode(), lstatFi.Mode())
@@ -336,9 +332,10 @@ func TestVSSFS(t *testing.T) {
data, err := io.ReadAll(f)
rtest.OK(t, err)
rtest.Equals(t, "example", string(data), "unexpected file content")
rtest.OK(t, f.Close())
node, err := localVss.NodeFromFileInfo(tempfile, statFi, false)
node, err := f.ToNode(false)
rtest.OK(t, err)
rtest.Equals(t, node.Mode, statFi.Mode())
rtest.Equals(t, node.Mode, lstatFi.Mode())
rtest.OK(t, f.Close())
}

View File

@@ -81,12 +81,6 @@ func (fs *Reader) OpenFile(name string, flag int) (f File, err error) {
return nil, pathError("open", name, syscall.ENOENT)
}
// Stat returns a FileInfo describing the named file. If there is an error, it
// will be of type *os.PathError.
func (fs *Reader) Stat(name string) (os.FileInfo, error) {
return fs.Lstat(name)
}
// Lstat returns the FileInfo structure describing the named file.
// If the file is a symbolic link, the returned FileInfo
// describes the symbolic link. Lstat makes no attempt to follow the link.

View File

@@ -10,7 +10,6 @@ import (
// FS bundles all methods needed for a file system.
type FS interface {
OpenFile(name string, flag int) (File, error)
Stat(name string) (os.FileInfo, error)
Lstat(name string) (os.FileInfo, error)
DeviceID(fi os.FileInfo) (deviceID uint64, err error)
ExtendedStat(fi os.FileInfo) ExtendedFileInfo