"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
build: fix linting issues reported by running golangci-lint with different GOOS
albertony7ee22fcdf96f
diff --git a/backend/azureblob/azureblob_unsupported.go b/backend/azureblob/azureblob_unsupported.goindex b5ccf8643..50fcea34c 100644--- a/backend/azureblob/azureblob_unsupported.go+++ b/backend/azureblob/azureblob_unsupported.go@@ -3,4 +3,5 @@//go:build plan9 || solaris || js+// Package azureblob provides an interface to the Microsoft Azure blob object storage systempackage azureblobdiff --git a/backend/azurefiles/azurefiles_unsupported.go b/backend/azurefiles/azurefiles_unsupported.goindex f261676fd..d2723e62f 100644--- a/backend/azurefiles/azurefiles_unsupported.go+++ b/backend/azurefiles/azurefiles_unsupported.go@@ -3,4 +3,5 @@//go:build plan9 || js+// Package azurefiles provides an interface to Microsoft Azure Filespackage azurefilesdiff --git a/backend/cache/cache_unsupported.go b/backend/cache/cache_unsupported.goindex 8ce32ee66..8c94aaf26 100644--- a/backend/cache/cache_unsupported.go+++ b/backend/cache/cache_unsupported.go@@ -3,4 +3,5 @@//go:build plan9 || js+// Package cache implements a virtual provider to cache existing remotes.package cachediff --git a/backend/cache/utils_test.go b/backend/cache/utils_test.goindex c02d86ce9..9f85b0155 100644--- a/backend/cache/utils_test.go+++ b/backend/cache/utils_test.go@@ -1,3 +1,6 @@+//go:build !plan9 && !js+// +build !plan9,!js+package cacheimport bolt "go.etcd.io/bbolt"diff --git a/backend/hdfs/hdfs_unsupported.go b/backend/hdfs/hdfs_unsupported.goindex 02305691b..a14c7725c 100644--- a/backend/hdfs/hdfs_unsupported.go+++ b/backend/hdfs/hdfs_unsupported.go@@ -3,4 +3,5 @@//go:build plan9+// Package hdfs provides an interface to the HDFS storage system.package hdfsdiff --git a/backend/local/about_unix.go b/backend/local/about_unix.goindex 24134c794..f8dce54e4 100644--- a/backend/local/about_unix.go+++ b/backend/local/about_unix.go@@ -23,9 +23,9 @@ func (f *Fs) About(ctx context.Context) (*fs.Usage, error) {}bs := int64(s.Bsize) // nolint: unconvertusage := &fs.Usage{- Total: fs.NewUsageValue(bs * int64(s.Blocks)), // quota of bytes that can be used- Used: fs.NewUsageValue(bs * int64(s.Blocks-s.Bfree)), // bytes in use- Free: fs.NewUsageValue(bs * int64(s.Bavail)), // bytes which can be uploaded before reaching the quota+ Total: fs.NewUsageValue(bs * int64(s.Blocks)), //nolint: unconvert // quota of bytes that can be used+ Used: fs.NewUsageValue(bs * int64(s.Blocks-s.Bfree)), //nolint: unconvert // bytes in use+ Free: fs.NewUsageValue(bs * int64(s.Bavail)), //nolint: unconvert // bytes which can be uploaded before reaching the quota}return usage, nil}diff --git a/backend/local/metadata_other.go b/backend/local/metadata_other.goindex c32c89f26..dc6a5a736 100644--- a/backend/local/metadata_other.go+++ b/backend/local/metadata_other.go@@ -1,4 +1,4 @@-//go:build plan9 || js+//go:build dragonfly || plan9 || jspackage localdiff --git a/backend/local/xattr_unsupported.go b/backend/local/xattr_unsupported.goindex e63c25492..20c86d07a 100644--- a/backend/local/xattr_unsupported.go+++ b/backend/local/xattr_unsupported.go@@ -1,6 +1,7 @@+// The pkg/xattr module doesn't compile for openbsd or plan9+//go:build openbsd || plan9-// The pkg/xattr module doesn't compile for openbsd or plan9package localimport "github.com/rclone/rclone/fs"diff --git a/backend/oracleobjectstorage/oracleobjectstorage_unsupported.go b/backend/oracleobjectstorage/oracleobjectstorage_unsupported.goindex 07d8fd242..ccbc39316 100644--- a/backend/oracleobjectstorage/oracleobjectstorage_unsupported.go+++ b/backend/oracleobjectstorage/oracleobjectstorage_unsupported.go@@ -3,4 +3,5 @@//go:build plan9 || solaris || js+// Package oracleobjectstorage provides an interface to the OCI object storage system.package oracleobjectstoragediff --git a/backend/qingstor/qingstor_unsupported.go b/backend/qingstor/qingstor_unsupported.goindex 209d909bc..e16a2e80c 100644--- a/backend/qingstor/qingstor_unsupported.go+++ b/backend/qingstor/qingstor_unsupported.go@@ -3,4 +3,6 @@//go:build plan9 || js+// Package qingstor provides an interface to QingStor object storage+// Home: https://www.qingcloud.com/package qingstordiff --git a/backend/sftp/sftp_unsupported.go b/backend/sftp/sftp_unsupported.goindex 8dc950374..67794bc4f 100644--- a/backend/sftp/sftp_unsupported.go+++ b/backend/sftp/sftp_unsupported.go@@ -3,4 +3,5 @@//go:build plan9+// Package sftp provides a filesystem interface using github.com/pkg/sftppackage sftpdiff --git a/backend/storj/storj_unsupported.go b/backend/storj/storj_unsupported.goindex 67f9ebdfd..c3c731594 100644--- a/backend/storj/storj_unsupported.go+++ b/backend/storj/storj_unsupported.go@@ -1,3 +1,4 @@//go:build plan9+// Package storj provides an interface to Storj decentralized object storage.package storjdiff --git a/cmd/cachestats/cachestats_unsupported.go b/cmd/cachestats/cachestats_unsupported.goindex 089ba751a..1ab469e91 100644--- a/cmd/cachestats/cachestats_unsupported.go+++ b/cmd/cachestats/cachestats_unsupported.go@@ -3,4 +3,5 @@//go:build plan9 || js+// Package cachestats provides the cachestats command.package cachestatsdiff --git a/cmd/ncdu/ncdu_unsupported.go b/cmd/ncdu/ncdu_unsupported.goindex e1f6430c2..34d99ed6c 100644--- a/cmd/ncdu/ncdu_unsupported.go+++ b/cmd/ncdu/ncdu_unsupported.go@@ -3,4 +3,5 @@//go:build plan9 || js+// Package ncdu implements a text based user interface for exploring a remotepackage ncdudiff --git a/cmd/serve/ftp/ftp_unsupported.go b/cmd/serve/ftp/ftp_unsupported.goindex 7fa857560..f4c5415db 100644--- a/cmd/serve/ftp/ftp_unsupported.go+++ b/cmd/serve/ftp/ftp_unsupported.go@@ -3,9 +3,10 @@//go:build plan9+// Package ftp implements an FTP server for rclonepackage ftpimport "github.com/spf13/cobra"// Command definition is nil to show not implemented-var Command *cobra.Command = nil+var Command *cobra.Commanddiff --git a/cmd/serve/sftp/sftp_unsupported.go b/cmd/serve/sftp/sftp_unsupported.goindex 9f0df6499..22e0673a7 100644--- a/cmd/serve/sftp/sftp_unsupported.go+++ b/cmd/serve/sftp/sftp_unsupported.go@@ -3,9 +3,10 @@//go:build plan9+// Package sftp implements an SFTP server to serve an rclone VFSpackage sftpimport "github.com/spf13/cobra"// Command definition is nil to show not implemented-var Command *cobra.Command = nil+var Command *cobra.Commanddiff --git a/fs/fserrors/enospc_error_notsupported.go b/fs/fserrors/enospc_error_notsupported.goindex 30f5a6b3c..f1f1e94de 100644--- a/fs/fserrors/enospc_error_notsupported.go+++ b/fs/fserrors/enospc_error_notsupported.go@@ -2,7 +2,7 @@package fserrors-// IsErrNoSpace() on plan9 returns false because+// IsErrNoSpace on plan9 returns false because// plan9 does not support syscall.ENOSPC error.func IsErrNoSpace(cause error) (isNoSpc bool) {isNoSpc = falsediff --git a/fs/fserrors/error_syscall_test.go b/fs/fserrors/error_syscall_test.gonew file mode 100644index 000000000..f2523b6fd--- /dev/null+++ b/fs/fserrors/error_syscall_test.go@@ -0,0 +1,74 @@+//go:build !plan9+// +build !plan9++package fserrors++import (+ "fmt"+ "net"+ "net/url"+ "os"+ "syscall"+ "testing"++ "github.com/stretchr/testify/assert"+)++// make a plausible network error with the underlying errno+func makeNetErr(errno syscall.Errno) error {+ return &net.OpError{+ Op: "write",+ Net: "tcp",+ Source: &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 123},+ Addr: &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 8080},+ Err: &os.SyscallError{+ Syscall: "write",+ Err: errno,+ },+ }+}++func TestWithSyscallCause(t *testing.T) {+ for i, test := range []struct {+ err error+ wantRetriable bool+ wantErr error+ }{+ {makeNetErr(syscall.EAGAIN), true, syscall.EAGAIN},+ {makeNetErr(syscall.Errno(123123123)), false, syscall.Errno(123123123)},+ } {+ gotRetriable, gotErr := Cause(test.err)+ what := fmt.Sprintf("test #%d: %v", i, test.err)+ assert.Equal(t, test.wantErr, gotErr, what)+ assert.Equal(t, test.wantRetriable, gotRetriable, what)+ }+}++func TestWithSyscallShouldRetry(t *testing.T) {+ for i, test := range []struct {+ err error+ want bool+ }{+ {makeNetErr(syscall.EAGAIN), true},+ {makeNetErr(syscall.Errno(123123123)), false},+ {+ wrap(&url.Error{+ Op: "post",+ URL: "http://localhost/",+ Err: makeNetErr(syscall.EPIPE),+ }, "potato error"),+ true,+ },+ {+ wrap(&url.Error{+ Op: "post",+ URL: "http://localhost/",+ Err: makeNetErr(syscall.Errno(123123123)),+ }, "listing error"),+ false,+ },+ } {+ got := ShouldRetry(test.err)+ assert.Equal(t, test.want, got, fmt.Sprintf("test #%d: %v", i, test.err))+ }+}diff --git a/fs/fserrors/error_test.go b/fs/fserrors/error_test.goindex ec8426660..21bdaf5cb 100644--- a/fs/fserrors/error_test.go+++ b/fs/fserrors/error_test.go@@ -5,10 +5,7 @@ import ("errors""fmt""io"- "net""net/url"- "os"- "syscall""testing""time"@@ -41,20 +38,6 @@ func wrap(err error, message string) error {var errUseOfClosedNetworkConnection = errors.New("use of closed network connection")-// make a plausible network error with the underlying errno-func makeNetErr(errno syscall.Errno) error {- return &net.OpError{- Op: "write",- Net: "tcp",- Source: &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 123},- Addr: &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 8080},- Err: &os.SyscallError{- Syscall: "write",- Err: errno,- },- }-}-type myError1 struct {Err error}@@ -121,8 +104,6 @@ func TestCause(t *testing.T) {{fmt.Errorf("potato: %w", errPotato), false, errPotato},{fmt.Errorf("potato2: %w", wrap(errPotato, "potato")), false, errPotato},{errUseOfClosedNetworkConnection, false, errUseOfClosedNetworkConnection},- {makeNetErr(syscall.EAGAIN), true, syscall.EAGAIN},- {makeNetErr(syscall.Errno(123123123)), false, syscall.Errno(123123123)},{eNil1, false, eNil1},{eNil2, false, eNil2.Err},{myError1{io.EOF}, false, io.EOF},@@ -151,27 +132,9 @@ func TestShouldRetry(t *testing.T) {{fmt.Errorf("connection: %w", errUseOfClosedNetworkConnection), true},{io.EOF, true},{io.ErrUnexpectedEOF, true},- {makeNetErr(syscall.EAGAIN), true},- {makeNetErr(syscall.Errno(123123123)), false},{&url.Error{Op: "post", URL: "/", Err: io.EOF}, true},{&url.Error{Op: "post", URL: "/", Err: errUseOfClosedNetworkConnection}, true},{&url.Error{Op: "post", URL: "/", Err: fmt.Errorf("net/http: HTTP/1.x transport connection broken: %v", fmt.Errorf("http: ContentLength=%d with Body length %d", 100663336, 99590598))}, true},- {- wrap(&url.Error{- Op: "post",- URL: "http://localhost/",- Err: makeNetErr(syscall.EPIPE),- }, "potato error"),- true,- },- {- wrap(&url.Error{- Op: "post",- URL: "http://localhost/",- Err: makeNetErr(syscall.Errno(123123123)),- }, "listing error"),- false,- },} {got := ShouldRetry(test.err)assert.Equal(t, test.want, got, fmt.Sprintf("test #%d: %v", i, test.err))diff --git a/fs/logger/logger_test.go b/fs/logger/logger_test.goindex 0e53563ce..d306cdd13 100644--- a/fs/logger/logger_test.go+++ b/fs/logger/logger_test.go@@ -1,3 +1,6 @@+//go:build !plan9+// +build !plan9+package logger_testimport (diff --git a/lib/kv/unsupported.go b/lib/kv/unsupported.goindex cf2f5d56a..c4bb0deff 100644--- a/lib/kv/unsupported.go+++ b/lib/kv/unsupported.go@@ -1,5 +1,6 @@//go:build plan9 || js+// Package kv provides key/value database.package kvimport (diff --git a/vfs/vfstest/write_other.go b/vfs/vfstest/write_other.gonew file mode 100644index 000000000..f95c3efa1--- /dev/null+++ b/vfs/vfstest/write_other.go@@ -0,0 +1,20 @@+//go:build !linux && !darwin && !freebsd && !windows+// +build !linux,!darwin,!freebsd,!windows++package vfstest++import (+ "errors"+ "runtime"+ "testing"+)++// TestWriteFileDoubleClose tests double close on write+func TestWriteFileDoubleClose(t *testing.T) {+ t.Skip("not supported on " + runtime.GOOS)+}++// writeTestDup performs the platform-specific implementation of the dup() unix+func writeTestDup(oldfd uintptr) (uintptr, error) {+ return 0, errors.New("not supported on " + runtime.GOOS)+}diff --git a/vfs/vfstest/write_non_unix.go b/vfs/vfstest/write_windows.gosimilarity index 92%rename from vfs/vfstest/write_non_unix.gorename to vfs/vfstest/write_windows.goindex 161354434..227e302a3 100644--- a/vfs/vfstest/write_non_unix.go+++ b/vfs/vfstest/write_windows.go@@ -1,4 +1,4 @@-//go:build !linux && !darwin && !freebsd+//go:build windowspackage vfstest