diff --git a/api/bucket.go b/api/bucket.go index f91ca0f51..fc28ed7d9 100644 --- a/api/bucket.go +++ b/api/bucket.go @@ -322,13 +322,13 @@ func (h *BucketOwner) getDir(ctx *gin.Context, input string, filter tar.Filter) tarWriter.Close() }() err := tarWriter.AssertDir(input) - if err != nil { - _ = ctx.Error(err) - return - } else { + if err == nil { h.Attachment(ctx, pathlib.Base(input)+".tar.gz") ctx.Writer.Header().Set(Directory, DirectoryExpand) ctx.Status(http.StatusOK) + } else { + _ = ctx.Error(err) + return } _ = tarWriter.AddDir(input) return