rm: Fix sending an object/version to removal with --no-current flag (#4038)

Do no miss sending object/version to contentCh when there is deletion
result available.

This commit fixes issues seen when some objects/versions are not deleted
when --no-current is passed.

Co-authored-by: Anis Elleuch <anis@min.io>
This commit is contained in:
Anis Elleuch
2022-04-02 16:14:23 -07:00
committed by GitHub
co-authored by Anis Elleuch
parent 5a3ad93ab9
commit 033969a0bf
+46 -38
View File
@@ -459,27 +459,31 @@ func listAndRemove(url string, opts removeOpts) error {
continue
}
select {
case contentCh <- content:
case result := <-resultCh:
if result.Err != nil {
errorIf(result.Err.Trace(content.URL.Path),
"Failed to remove `"+content.URL.Path+"`.")
switch result.Err.ToGoError().(type) {
case PathInsufficientPermission:
// Ignore Permission error.
continue
sent := false
for !sent {
select {
case contentCh <- content:
sent = true
case result := <-resultCh:
if result.Err != nil {
errorIf(result.Err.Trace(content.URL.Path),
"Failed to remove `"+content.URL.Path+"`.")
switch result.Err.ToGoError().(type) {
case PathInsufficientPermission:
// Ignore Permission error.
continue
}
close(contentCh)
return exitStatus(globalErrorExitStatus)
}
close(contentCh)
return exitStatus(globalErrorExitStatus)
printMsg(rmMessage{
Key: path.Join(targetAlias, content.BucketName, result.ObjectName),
Size: content.Size,
VersionID: content.VersionID,
DeleteMarker: result.DeleteMarker,
ModTime: content.Time,
})
}
printMsg(rmMessage{
Key: path.Join(targetAlias, content.BucketName, result.ObjectName),
Size: content.Size,
VersionID: content.VersionID,
DeleteMarker: result.DeleteMarker,
ModTime: content.Time,
})
}
}
perObjectVersions = []*ClientContent{}
@@ -570,27 +574,31 @@ func listAndRemove(url string, opts removeOpts) error {
continue
}
select {
case contentCh <- content:
case result := <-resultCh:
if result.Err != nil {
errorIf(result.Err.Trace(content.URL.Path),
"Failed to remove `"+content.URL.Path+"`.")
switch result.Err.ToGoError().(type) {
case PathInsufficientPermission:
// Ignore Permission error.
continue
sent := false
for !sent {
select {
case contentCh <- content:
sent = true
case result := <-resultCh:
if result.Err != nil {
errorIf(result.Err.Trace(content.URL.Path),
"Failed to remove `"+content.URL.Path+"`.")
switch result.Err.ToGoError().(type) {
case PathInsufficientPermission:
// Ignore Permission error.
continue
}
close(contentCh)
return exitStatus(globalErrorExitStatus)
}
close(contentCh)
return exitStatus(globalErrorExitStatus)
printMsg(rmMessage{
Key: path.Join(targetAlias, result.BucketName, result.ObjectName),
Size: content.Size,
VersionID: content.VersionID,
DeleteMarker: result.DeleteMarker,
ModTime: content.Time,
})
}
printMsg(rmMessage{
Key: path.Join(targetAlias, result.BucketName, result.ObjectName),
Size: content.Size,
VersionID: content.VersionID,
DeleteMarker: result.DeleteMarker,
ModTime: content.Time,
})
}
}
}