| 49 | } |
| 50 | |
| 51 | func (rw *Azure) ClearBlock(blockID uuid.UUID, tenantID string) error { |
| 52 | var warning error |
| 53 | if len(tenantID) == 0 { |
| 54 | return fmt.Errorf("empty tenant id") |
| 55 | } |
| 56 | |
| 57 | if blockID == uuid.Nil { |
| 58 | return fmt.Errorf("empty block id") |
| 59 | } |
| 60 | |
| 61 | ctx := context.TODO() |
| 62 | |
| 63 | prefix := backend.RootPath(blockID, tenantID, rw.cfg.Prefix) |
| 64 | pager := rw.containerClient.NewListBlobsHierarchyPager("", &container.ListBlobsHierarchyOptions{ |
| 65 | Include: container.ListBlobsInclude{}, |
| 66 | Prefix: &prefix, |
| 67 | }) |
| 68 | |
| 69 | for pager.More() { |
| 70 | page, err := pager.NextPage(ctx) |
| 71 | if err != nil { |
| 72 | warning = err |
| 73 | continue |
| 74 | } |
| 75 | |
| 76 | for _, b := range page.Segment.BlobItems { |
| 77 | if b.Name == nil { |
| 78 | return fmt.Errorf("unexpected empty blob name when listing %s: %w", prefix, err) |
| 79 | } |
| 80 | |
| 81 | err = rw.Delete(ctx, *b.Name, []string{}, nil) |
| 82 | if err != nil { |
| 83 | warning = err |
| 84 | continue |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | return warning |
| 90 | } |
| 91 | |
| 92 | func (rw *Azure) CompactedBlockMeta(blockID uuid.UUID, tenantID string) (*backend.CompactedBlockMeta, error) { |
| 93 | if len(tenantID) == 0 { |