Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

serve s3: make --no-cleanup a deprecated alias of --directory-markers

Nick Craig-Woodba5c6c89fdfb
diff --git a/cmd/serve/s3/list_test.go b/cmd/serve/s3/list_test.go
index dc4a754ad..cadadea72 100644
--- a/cmd/serve/s3/list_test.go
+++ b/cmd/serve/s3/list_test.go
@@ -470,3 +470,13 @@ func TestListDirectoryMarkers(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, []string{"a/", "implicit/", "implicit/file", "x/", "x/w"}, all())
}
+
+// TestListNoCleanup checks the deprecated --no-cleanup is
+// --directory-markers.
+func TestListNoCleanup(t *testing.T) {
+ opt := Opt
+ opt.NoCleanup = true
+ b := newListBackendOpt(t, opt, "bucket/a/b")
+ require.NoError(t, b.deleteObject(context.Background(), "bucket", "a/b"))
+ assert.Equal(t, []string{"a/"}, listPages(t, b, listPrefix("", ""), 1000))
+}
diff --git a/cmd/serve/s3/s3.go b/cmd/serve/s3/s3.go
index c69812ee5..4a131be63 100644
--- a/cmd/serve/s3/s3.go
+++ b/cmd/serve/s3/s3.go
@@ -36,7 +36,7 @@ var OptionsInfo = fs.Options{{
}, {
Name: "no_cleanup",
Default: false,
- Help: "Not to cleanup empty folder after object is deleted",
+ Help: "Deprecated: use --directory-markers instead",
}, {
Name: "disable_multipart_streaming",
Default: false,
diff --git a/cmd/serve/s3/serve_s3.md b/cmd/serve/s3/serve_s3.md
index e8660a117..67ac1d022 100644
--- a/cmd/serve/s3/serve_s3.md
+++ b/cmd/serve/s3/serve_s3.md
@@ -444,7 +444,8 @@ folders not in the root.
When using `PutObject` or `DeleteObject`, rclone will automatically
create or clean up empty folders. If you don't want to clean up empty
-folders automatically, use `--no-cleanup`.
+folders automatically, use `--directory-markers` (see [Object
+names](#object-names)). The deprecated `--no-cleanup` does the same.
When using `ListObjects` with the delimiter `/`, rclone lists the
directory the prefix is in, showing its subdirectories as common
diff --git a/cmd/serve/s3/server.go b/cmd/serve/s3/server.go
index 49cfb78aa..2204681cf 100644
--- a/cmd/serve/s3/server.go
+++ b/cmd/serve/s3/server.go
@@ -59,6 +59,11 @@ func newServer(ctx context.Context, f fs.Fs, opt *Options, vfsOpt *vfscommon.Opt
}
}()
+ if w.opt.NoCleanup {
+ fs.Logf("serve s3", "--no-cleanup is deprecated, use --directory-markers instead")
+ w.opt.DirectoryMarkers = true
+ }
+
if w.opt.EtagHash != "" && w.opt.EtagHash != "auto" {
err := w.etagHashType.Set(w.opt.EtagHash)
if err != nil {