Files
kopia/cli/command_blob_delete.go
Julio Lopez 8098f49c90 chore(ci): remove exclusion for unused ctx parameters (#4530)
Remove unused-parameter exclusion for `ctx` in revive linter.

---------

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-26 23:11:36 -07:00

38 lines
792 B
Go

package cli
import (
"context"
"github.com/pkg/errors"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/blob"
)
type commandBlobDelete struct {
blobIDs []string
svc appServices
}
func (c *commandBlobDelete) setup(svc appServices, parent commandParent) {
cmd := parent.Command("delete", "Delete blobs by ID").Alias("remove").Alias("rm")
cmd.Arg("blobIDs", "Blob IDs").Required().StringsVar(&c.blobIDs)
cmd.Action(svc.directRepositoryWriteAction(c.run))
c.svc = svc
}
func (c *commandBlobDelete) run(ctx context.Context, rep repo.DirectRepositoryWriter) error {
c.svc.advancedCommand()
for _, b := range c.blobIDs {
err := rep.BlobStorage().DeleteBlob(ctx, blob.ID(b))
if err != nil {
return errors.Wrapf(err, "error deleting %v", b)
}
}
return nil
}