"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
lib/bucket: add IsAllSlashes function
Nick Craig-Woodb4990cd858c5
diff --git a/lib/bucket/bucket.go b/lib/bucket/bucket.goindex 44aac0bb3..9b0b31afd 100644--- a/lib/bucket/bucket.go+++ b/lib/bucket/bucket.go@@ -42,6 +42,21 @@ func Join(path1, path2 string) string {return strings.TrimSuffix(path1, "/") + "/" + strings.TrimPrefix(path2, "/")}+// IsAllSlashes returns true if s is all / characters.+//+// It returns false if s is "".+func IsAllSlashes(s string) bool {+ if len(s) == 0 {+ return false+ }+ for _, c := range s {+ if c != '/' {+ return false+ }+ }+ return true+}+// Cache stores whether buckets are available and their IDstype Cache struct {mu sync.Mutex // mutex to protect created and deleteddiff --git a/lib/bucket/bucket_test.go b/lib/bucket/bucket_test.goindex 1a36ea300..df4b7d95b 100644--- a/lib/bucket/bucket_test.go+++ b/lib/bucket/bucket_test.go@@ -45,6 +45,24 @@ func TestJoin(t *testing.T) {}}+func TestIsAllSlashes(t *testing.T) {+ for _, test := range []struct {+ in string+ want bool+ }{+ {in: "", want: false},+ {in: "/", want: true},+ {in: "x/", want: false},+ {in: "/x", want: false},+ {in: "//", want: true},+ {in: "/x/", want: false},+ {in: "///", want: true},+ } {+ got := IsAllSlashes(test.in)+ assert.Equal(t, test.want, got, test.in)+ }+}+func TestCache(t *testing.T) {c := NewCache()errBoom := errors.New("boom")