(ctx context.Context, name string, keypath backend.KeyPath, data io.Reader, _ int64, version backend.Version)
| 395 | } |
| 396 | |
| 397 | func (rw *readerWriter) WriteVersioned(ctx context.Context, name string, keypath backend.KeyPath, data io.Reader, _ int64, version backend.Version) (backend.Version, error) { |
| 398 | keypath = backend.KeyPathWithPrefix(keypath, rw.cfg.Prefix) |
| 399 | derivedCtx, span := tracer.Start(ctx, "gcs.WriteVersioned", trace.WithAttributes( |
| 400 | attribute.String("object", name), |
| 401 | )) |
| 402 | defer span.End() |
| 403 | |
| 404 | preconditions, err := createPreconditions(version) |
| 405 | if err != nil { |
| 406 | return "", err |
| 407 | } |
| 408 | |
| 409 | w := rw.writer(derivedCtx, backend.ObjectFileName(keypath, name), &preconditions) |
| 410 | |
| 411 | _, err = io.Copy(w, data) |
| 412 | if err != nil { |
| 413 | w.Close() |
| 414 | span.SetStatus(codes.Error, "failed to write") |
| 415 | return "", fmt.Errorf("failed to write: %w", err) |
| 416 | } |
| 417 | |
| 418 | err = w.Close() |
| 419 | if err != nil { |
| 420 | return "", err |
| 421 | } |
| 422 | |
| 423 | return toVersion(w.Attrs().Generation), nil |
| 424 | } |
| 425 | |
| 426 | func (rw *readerWriter) DeleteVersioned(ctx context.Context, name string, keypath backend.KeyPath, version backend.Version) error { |
| 427 | keypath = backend.KeyPathWithPrefix(keypath, rw.cfg.Prefix) |
nothing calls this directly
no test coverage detected