(ctx context.Context, m blob.Metadata, src blob.Reader, dst blob.Storage)
| 304 | } |
| 305 | |
| 306 | func (c *commandRepositorySyncTo) syncCopyBlob(ctx context.Context, m blob.Metadata, src blob.Reader, dst blob.Storage) error { |
| 307 | var data gather.WriteBuffer |
| 308 | defer data.Close() |
| 309 | |
| 310 | if err := src.GetBlob(ctx, m.BlobID, 0, -1, &data); err != nil { |
| 311 | if errors.Is(err, blob.ErrBlobNotFound) { |
| 312 | log(ctx).Infof("ignoring BLOB not found: %v", m.BlobID) |
| 313 | return nil |
| 314 | } |
| 315 | |
| 316 | return errors.Wrapf(err, "error reading blob '%v' from source", m.BlobID) |
| 317 | } |
| 318 | |
| 319 | opt := blob.PutOptions{} |
| 320 | if c.repositorySyncTimes { |
| 321 | opt.SetModTime = m.Timestamp |
| 322 | } |
| 323 | |
| 324 | if err := dst.PutBlob(ctx, m.BlobID, data.Bytes(), opt); err != nil { |
| 325 | if errors.Is(err, blob.ErrSetTimeUnsupported) { |
| 326 | // run again without SetModTime, emit a warning |
| 327 | opt.SetModTime = time.Time{} |
| 328 | |
| 329 | log(ctx).Warn("destination repository does not support preserving modification times") |
| 330 | |
| 331 | c.repositorySyncTimes = false |
| 332 | |
| 333 | err = dst.PutBlob(ctx, m.BlobID, data.Bytes(), opt) |
| 334 | } |
| 335 | |
| 336 | if err != nil { |
| 337 | return errors.Wrapf(err, "error writing blob '%v' to destination", m.BlobID) |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | return nil |
| 342 | } |
| 343 | |
| 344 | func syncDeleteBlob(ctx context.Context, m blob.Metadata, dst blob.Storage) error { |
| 345 | err := dst.DeleteBlob(ctx, m.BlobID) |
no test coverage detected