union: implement missing methods

Implement these missing methods:

- CleanUp

And declare these ones unimplementable:

- UnWrap
- WrapFs
- SetWrapper
- UserInfo
- Disconnect
- PublicLink
- PutUnchecked
- MergeDirs
- OpenWriterAt
This commit is contained in:
Nick Craig-Wood 2023-05-12 11:44:01 +01:00
parent 487e4f09b3
commit 97be9015a4
2 changed files with 38 additions and 14 deletions

View File

@ -801,6 +801,24 @@ func (f *Fs) Shutdown(ctx context.Context) error {
return errs.Err() return errs.Err()
} }
// CleanUp the trash in the Fs
//
// Implement this if you have a way of emptying the trash or
// otherwise cleaning up old versions of files.
func (f *Fs) CleanUp(ctx context.Context) error {
errs := Errors(make([]error, len(f.upstreams)))
multithread(len(f.upstreams), func(i int) {
u := f.upstreams[i]
if do := u.Features().CleanUp; do != nil {
err := do(ctx)
if err != nil {
errs[i] = fmt.Errorf("%s: %w", u.Name(), err)
}
}
})
return errs.Err()
}
// NewFs constructs an Fs from the path. // NewFs constructs an Fs from the path.
// //
// The returned Fs is the actual Fs, referenced by remote in the config // The returned Fs is the actual Fs, referenced by remote in the config
@ -963,4 +981,5 @@ var (
_ fs.Abouter = (*Fs)(nil) _ fs.Abouter = (*Fs)(nil)
_ fs.ListRer = (*Fs)(nil) _ fs.ListRer = (*Fs)(nil)
_ fs.Shutdowner = (*Fs)(nil) _ fs.Shutdowner = (*Fs)(nil)
_ fs.CleanUpper = (*Fs)(nil)
) )

View File

@ -11,6 +11,11 @@ import (
"github.com/rclone/rclone/fstest/fstests" "github.com/rclone/rclone/fstest/fstests"
) )
var (
unimplementableFsMethods = []string{"UnWrap", "WrapFs", "SetWrapper", "UserInfo", "Disconnect", "PublicLink", "PutUnchecked", "MergeDirs", "OpenWriterAt"}
unimplementableObjectMethods = []string{}
)
// TestIntegration runs integration tests against the remote // TestIntegration runs integration tests against the remote
func TestIntegration(t *testing.T) { func TestIntegration(t *testing.T) {
if *fstest.RemoteName == "" { if *fstest.RemoteName == "" {
@ -18,8 +23,8 @@ func TestIntegration(t *testing.T) {
} }
fstests.Run(t, &fstests.Opt{ fstests.Run(t, &fstests.Opt{
RemoteName: *fstest.RemoteName, RemoteName: *fstest.RemoteName,
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"}, UnimplementableFsMethods: unimplementableFsMethods,
UnimplementableObjectMethods: []string{"MimeType"}, UnimplementableObjectMethods: unimplementableObjectMethods,
}) })
} }
@ -39,8 +44,8 @@ func TestStandard(t *testing.T) {
{Name: name, Key: "create_policy", Value: "epmfs"}, {Name: name, Key: "create_policy", Value: "epmfs"},
{Name: name, Key: "search_policy", Value: "ff"}, {Name: name, Key: "search_policy", Value: "ff"},
}, },
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"}, UnimplementableFsMethods: unimplementableFsMethods,
UnimplementableObjectMethods: []string{"MimeType"}, UnimplementableObjectMethods: unimplementableObjectMethods,
QuickTestOK: true, QuickTestOK: true,
}) })
} }
@ -61,8 +66,8 @@ func TestRO(t *testing.T) {
{Name: name, Key: "create_policy", Value: "epmfs"}, {Name: name, Key: "create_policy", Value: "epmfs"},
{Name: name, Key: "search_policy", Value: "ff"}, {Name: name, Key: "search_policy", Value: "ff"},
}, },
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"}, UnimplementableFsMethods: unimplementableFsMethods,
UnimplementableObjectMethods: []string{"MimeType"}, UnimplementableObjectMethods: unimplementableObjectMethods,
QuickTestOK: true, QuickTestOK: true,
}) })
} }
@ -83,8 +88,8 @@ func TestNC(t *testing.T) {
{Name: name, Key: "create_policy", Value: "epmfs"}, {Name: name, Key: "create_policy", Value: "epmfs"},
{Name: name, Key: "search_policy", Value: "ff"}, {Name: name, Key: "search_policy", Value: "ff"},
}, },
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"}, UnimplementableFsMethods: unimplementableFsMethods,
UnimplementableObjectMethods: []string{"MimeType"}, UnimplementableObjectMethods: unimplementableObjectMethods,
QuickTestOK: true, QuickTestOK: true,
}) })
} }
@ -105,8 +110,8 @@ func TestPolicy1(t *testing.T) {
{Name: name, Key: "create_policy", Value: "lus"}, {Name: name, Key: "create_policy", Value: "lus"},
{Name: name, Key: "search_policy", Value: "all"}, {Name: name, Key: "search_policy", Value: "all"},
}, },
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"}, UnimplementableFsMethods: unimplementableFsMethods,
UnimplementableObjectMethods: []string{"MimeType"}, UnimplementableObjectMethods: unimplementableObjectMethods,
QuickTestOK: true, QuickTestOK: true,
}) })
} }
@ -127,8 +132,8 @@ func TestPolicy2(t *testing.T) {
{Name: name, Key: "create_policy", Value: "rand"}, {Name: name, Key: "create_policy", Value: "rand"},
{Name: name, Key: "search_policy", Value: "ff"}, {Name: name, Key: "search_policy", Value: "ff"},
}, },
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"}, UnimplementableFsMethods: unimplementableFsMethods,
UnimplementableObjectMethods: []string{"MimeType"}, UnimplementableObjectMethods: unimplementableObjectMethods,
QuickTestOK: true, QuickTestOK: true,
}) })
} }
@ -149,8 +154,8 @@ func TestPolicy3(t *testing.T) {
{Name: name, Key: "create_policy", Value: "all"}, {Name: name, Key: "create_policy", Value: "all"},
{Name: name, Key: "search_policy", Value: "all"}, {Name: name, Key: "search_policy", Value: "all"},
}, },
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"}, UnimplementableFsMethods: unimplementableFsMethods,
UnimplementableObjectMethods: []string{"MimeType"}, UnimplementableObjectMethods: unimplementableObjectMethods,
QuickTestOK: true, QuickTestOK: true,
}) })
} }