Files
kopia/cli/command_blob_delete.go
Jarek Kowalski 6cb9b8fa4f repo: refactored public API (#318)
* This is 99% mechanical:

Extracted repo.Repository interface that only exposes high-level object and manifest management methods, but not blob nor content management.

Renamed old *repo.Repository to *repo.DirectRepository

Reviewed codebase to only depend on repo.Repository as much as possible, but added way for low-level CLI commands to use DirectRepository.

* PR fixes
2020-03-26 08:04:01 -07:00

31 lines
651 B
Go

package cli
import (
"context"
"github.com/pkg/errors"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/blob"
)
var (
blobDeleteCommand = blobCommands.Command("delete", "Delete blobs by ID").Alias("rm")
blobDeleteBlobIDs = blobDeleteCommand.Arg("blobIDs", "Blob IDs").Required().Strings()
)
func runDeleteBlobs(ctx context.Context, rep *repo.DirectRepository) error {
for _, b := range *blobDeleteBlobIDs {
err := rep.Blobs.DeleteBlob(ctx, blob.ID(b))
if err != nil {
return errors.Wrapf(err, "error deleting %v", b)
}
}
return nil
}
func init() {
blobDeleteCommand.Action(directRepositoryAction(runDeleteBlobs))
}