MCPcopy
hub / github.com/kopia/kopia / recoverFormatBlob

Method recoverFormatBlob

cli/command_repository_repair.go:82–115  ·  view source on GitHub ↗
(ctx context.Context, st blob.Storage, prefixes []string)

Source from the content-addressed store, hash-verified

80}
81
82func (c *commandRepositoryRepair) recoverFormatBlob(ctx context.Context, st blob.Storage, prefixes []string) error {
83 errSuccess := errors.New("success")
84
85 for _, prefix := range prefixes {
86 err := st.ListBlobs(ctx, blob.ID(prefix), func(bi blob.Metadata) error {
87 log(ctx).Infof("looking for replica of format blob in %v...", bi.BlobID)
88
89 if b, err := format.RecoverFormatBlob(ctx, st, bi.BlobID, bi.Length); err == nil {
90 if !c.repairDryRun {
91 if puterr := st.PutBlob(ctx, format.KopiaRepositoryBlobID, gather.FromSlice(b), blob.PutOptions{}); puterr != nil {
92 return errors.Wrap(puterr, "error writing format blob")
93 }
94 }
95
96 log(ctx).Infof("recovered replica block from %v", bi.BlobID)
97
98 return errSuccess
99 }
100
101 return nil
102 })
103
104 switch {
105 case err == nil:
106 // do nothing
107 case errors.Is(err, errSuccess):
108 return nil
109 default:
110 return errors.Wrap(err, "unexpected error when listing blobs")
111 }
112 }
113
114 return errors.New("could not find a replica of a format blob")
115}

Callers 1

Calls 5

IDTypeAlias · 0.92
RecoverFormatBlobFunction · 0.92
FromSliceFunction · 0.92
ListBlobsMethod · 0.65
PutBlobMethod · 0.65

Tested by

no test coverage detected