mirror of
https://github.com/restic/restic.git
synced 2025-08-25 23:47:29 +00:00
fs: remove Stat from FS interface
This commit is contained in:
@@ -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.
|
||||
|
@@ -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))
|
||||
|
@@ -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())
|
||||
}
|
||||
|
@@ -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.
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user