From 6efe4d1df63b4cba6b08edbe6fbea0d6e83804bb Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Wed, 22 Feb 2023 06:21:40 +0100 Subject: [PATCH] perf: Only remove generated data when no bucket name specified (#16610) --- cmd/admin-handlers.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index 200dfb68b..3d047ceda 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -1217,6 +1217,7 @@ func (a adminAPIHandlers) ObjectSpeedTestHandler(w http.ResponseWriter, r *http. storageClass := strings.TrimSpace(r.Form.Get(peerRESTStorageClass)) customBucket := strings.TrimSpace(r.Form.Get(peerRESTBucket)) autotune := r.Form.Get("autotune") == "true" + noClear := r.Form.Get("noclear") == "true" size, err := strconv.Atoi(sizeStr) if err != nil { @@ -1258,14 +1259,16 @@ func (a adminAPIHandlers) ObjectSpeedTestHandler(w http.ResponseWriter, r *http. return } - if !bucketExists { + if !noClear && !bucketExists { defer deleteObjectPerfBucket(objectAPI) } } - defer objectAPI.DeleteObject(ctx, customBucket, speedTest+SlashSeparator, ObjectOptions{ - DeletePrefix: true, - }) + if !noClear { + defer objectAPI.DeleteObject(ctx, customBucket, speedTest+SlashSeparator, ObjectOptions{ + DeletePrefix: true, + }) + } // Freeze all incoming S3 API calls before running speedtest. globalNotificationSys.ServiceFreeze(ctx, true)