diff options
author | Jakob Borg <jakob@kastelo.net> | 2023-07-17 13:49:48 +0200 |
---|---|---|
committer | Jakob Borg <jakob@kastelo.net> | 2023-07-17 13:49:48 +0200 |
commit | fe35d5a465be5bfdc1d8c83d12e226d5f945097d (patch) | |
tree | f3e483db3c7a9755f054cddd60472e6608ea0e20 | |
parent | 2a860f0658791683a40f9a18206fd881a4dfd853 (diff) | |
download | syncthing-fe35d5a465be5bfdc1d8c83d12e226d5f945097d.tar.gz syncthing-fe35d5a465be5bfdc1d8c83d12e226d5f945097d.zip |
wip
-rw-r--r-- | lib/fs/basicfs.go | 4 | ||||
-rw-r--r-- | lib/fs/fakefs.go | 4 | ||||
-rw-r--r-- | lib/fs/filesystem.go | 21 | ||||
-rw-r--r-- | lib/fs/filesystem_copy_range_test.go | 4 | ||||
-rw-r--r-- | lib/fs/metrics.go | 4 |
5 files changed, 4 insertions, 33 deletions
diff --git a/lib/fs/basicfs.go b/lib/fs/basicfs.go index cb76de769..58afc0e27 100644 --- a/lib/fs/basicfs.go +++ b/lib/fs/basicfs.go @@ -350,10 +350,6 @@ func (f basicFile) Stat() (FileInfo, error) { return basicFileInfo{info}, nil } -func (f basicFile) underlying() (File, bool) { - return nil, false -} - // basicFileInfo implements the fs.FileInfo interface on top of an os.FileInfo. type basicFileInfo struct { os.FileInfo diff --git a/lib/fs/fakefs.go b/lib/fs/fakefs.go index bca00a9eb..65151dbc3 100644 --- a/lib/fs/fakefs.go +++ b/lib/fs/fakefs.go @@ -961,10 +961,6 @@ func (*fakeFile) Sync() error { return nil } -func (f *fakeFile) underlying() (File, bool) { - return nil, false -} - // fakeFileInfo is the stat result. type fakeFileInfo struct { fakeEntry // intentionally a copy of the struct diff --git a/lib/fs/filesystem.go b/lib/fs/filesystem.go index 436603361..959407739 100644 --- a/lib/fs/filesystem.go +++ b/lib/fs/filesystem.go @@ -94,10 +94,6 @@ type File interface { Sync() error } -type wrappedFile interface { - underlying() (File, bool) -} - // The FileInfo interface is almost the same as os.FileInfo, but with the // Sys method removed (as we don't want to expose whatever is underlying) // and with a couple of convenience methods added. @@ -364,23 +360,6 @@ func unwrapFilesystem(fs Filesystem, wrapperType filesystemWrapperType) (Filesys } } -func unwrapFileToBasic(f File) (File, bool) { - for { - basic, ok := f.(basicFile) - if ok { - return basic, true - } - wrapped, ok := f.(wrappedFile) - if !ok { - return nil, false - } - f, ok = wrapped.underlying() - if !ok { - return nil, false - } - } -} - // WriteFile writes data to the named file, creating it if necessary. // If the file does not exist, WriteFile creates it with permissions perm (before umask); // otherwise WriteFile truncates it before writing, without changing permissions. diff --git a/lib/fs/filesystem_copy_range_test.go b/lib/fs/filesystem_copy_range_test.go index 36c36c99b..04328be0f 100644 --- a/lib/fs/filesystem_copy_range_test.go +++ b/lib/fs/filesystem_copy_range_test.go @@ -320,11 +320,11 @@ func TestCopyRange(tttt *testing.T) { t.Fatal(err) } - srcBasic, ok := unwrapFileToBasic(src) + srcBasic, ok := unwrap(src).(basicFile) if !ok { t.Fatal("src file is not a basic file") } - dstBasic, ok := unwrapFileToBasic(dst) + dstBasic, ok := unwrap(dst).(basicFile) if !ok { t.Fatal("dst file is not a basic file") } diff --git a/lib/fs/metrics.go b/lib/fs/metrics.go index 9c876932f..fe09a9a18 100644 --- a/lib/fs/metrics.go +++ b/lib/fs/metrics.go @@ -288,6 +288,6 @@ func (m *metricsFile) Name() string { return m.next.Name() } -func (m *metricsFile) underlying() (File, bool) { - return m.next, true +func (m *metricsFile) unwrap() File { + return m.next } |