Features.Mask combined SlowModTime with AND, but it is a restriction. Wrapping backends such as crypt start with it false, so crypt over s3, swift, qingstor, oracleobjectstorage or ftp lost it and read the modtime when a fast fingerprint was wanted. This cost an extra transaction per file when downloading through crypt to local, and with --vfs-fast-fingerprint. Combine it with OR so the restriction propagates through Mask. Note that this changes the fast fingerprint for these wrapped remotes, so a VFS cache using --vfs-fast-fingerprint will treat its cached files as changed once after upgrading.
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package fs_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/rclone/rclone/fs"
|
|
"github.com/rclone/rclone/fstest/mockfs"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestFeaturesMaskRestrictions checks flags which restrict what can be
|
|
// done are kept if either Fs sets them.
|
|
func TestFeaturesMaskRestrictions(t *testing.T) {
|
|
ctx := context.Background()
|
|
for _, flag := range []struct {
|
|
name string
|
|
get func(*fs.Features) *bool
|
|
}{
|
|
{"NoMultiThreading", func(ft *fs.Features) *bool { return &ft.NoMultiThreading }},
|
|
{"SlowModTime", func(ft *fs.Features) *bool { return &ft.SlowModTime }},
|
|
} {
|
|
for _, test := range []struct {
|
|
wrapper, wrapped, want bool
|
|
}{
|
|
{false, false, false},
|
|
{false, true, true},
|
|
{true, false, true},
|
|
{true, true, true},
|
|
} {
|
|
f, err := mockfs.NewFs(ctx, "test", "root", nil)
|
|
require.NoError(t, err)
|
|
*flag.get(f.Features()) = test.wrapped
|
|
ft := &fs.Features{}
|
|
*flag.get(ft) = test.wrapper
|
|
ft.Mask(ctx, f)
|
|
assert.Equal(t, test.want, *flag.get(ft), "%s wrapper=%v wrapped=%v", flag.name, test.wrapper, test.wrapped)
|
|
}
|
|
}
|
|
}
|