validation for namespace removal (#3783)

This commit is contained in:
Ashish Kumar Sinha
2021-09-15 11:34:41 -07:00
committed by GitHub
parent 6bf64d9704
commit 1f2429c336
+4 -6
View File
@@ -210,7 +210,7 @@ func checkRmSyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[string
url = filepath.ToSlash(filepath.Clean(url))
// namespace removal applies only for non FS. So filter out if passed url represents a directory
dir := isAliasURLDir(ctx, url, encKeyDB, time.Time{})
if !dir {
if dir {
_, path := url2Alias(url)
isNamespaceRemoval = (path == "")
break
@@ -231,17 +231,15 @@ func checkRmSyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[string
// For all recursive or versions bulk deletion operations make sure to check for 'force' flag.
if (isVersions || isRecursive || isStdin) && !isForce {
if isNamespaceRemoval {
fatalIf(errDummy().Trace(),
"This operation results in site-wide removal of objects. If you are really sure, retry this command with ‘--dangerous’ and ‘--force’ flags.")
}
fatalIf(errDummy().Trace(),
"Removal requires --force flag. This operation is *IRREVERSIBLE*. Please review carefully before performing this *DANGEROUS* operation.")
}
if (isRecursive || isStdin) && isNamespaceRemoval && !isDangerous {
if isNamespaceRemoval && !(isDangerous && isForce) {
fatalIf(errDummy().Trace(),
"This operation results in site-wide removal of objects. If you are really sure, retry this command with ‘--dangerous’ and ‘--force’ flags.")
}
}
// Remove a single object or a single version in a versioned bucket