MCPcopy
hub / github.com/kopia/kopia / WriteKopiaRepositoryBlobWithID

Method WriteKopiaRepositoryBlobWithID

repo/format/format_blob.go:176–193  ·  view source on GitHub ↗

WriteKopiaRepositoryBlobWithID writes `kopia.repository` blob to a given storage under an alternate blobID.

(ctx context.Context, st blob.Storage, blobCfg BlobStorageConfiguration, id blob.ID)

Source from the content-addressed store, hash-verified

174
175// WriteKopiaRepositoryBlobWithID writes `kopia.repository` blob to a given storage under an alternate blobID.
176func (f *KopiaRepositoryJSON) WriteKopiaRepositoryBlobWithID(ctx context.Context, st blob.Storage, blobCfg BlobStorageConfiguration, id blob.ID) error {
177 buf := gather.NewWriteBuffer()
178 e := json.NewEncoder(buf)
179 e.SetIndent("", " ")
180
181 if err := e.Encode(f); err != nil {
182 return errors.Wrap(err, "unable to marshal format blob")
183 }
184
185 if err := st.PutBlob(ctx, id, buf.Bytes(), blob.PutOptions{
186 RetentionMode: blobCfg.RetentionMode,
187 RetentionPeriod: blobCfg.RetentionPeriod,
188 }); err != nil {
189 return errors.Wrapf(err, "unable to write format blob %q", id)
190 }
191
192 return nil
193}
194
195func encryptRepositoryBlobBytesAes256Gcm(data, masterKey, repositoryID []byte) ([]byte, error) {
196 res, err := crypto.EncryptAes256Gcm(data, masterKey, repositoryID)

Callers 2

SetUpgradeLockIntentMethod · 0.80

Calls 3

BytesMethod · 0.95
NewWriteBufferFunction · 0.92
PutBlobMethod · 0.65

Tested by

no test coverage detected