/go/store/blobstore: update comments

This commit is contained in:
coffeegoddd☕️✨
2026-02-06 09:08:18 -08:00
parent 7f6f4709ab
commit 5419d5279c
2 changed files with 11 additions and 3 deletions

View File

@@ -33,7 +33,12 @@ type Blobstore interface {
// Get returns a byte range of from the blob keyed by |key|, and the latest store version.
Get(ctx context.Context, key string, br BlobRange) (rc io.ReadCloser, size uint64, version string, err error)
// Put creates a new blob from |reader| keyed by |key|, it returns the latest store version.
// Put stores a blob from |reader| keyed by |key|, returning the latest store version.
//
// If |key| already exists, behavior is implementation-defined: some Blobstore
// implementations overwrite, while others may treat Put as idempotent and fast-succeed
// without consuming |reader|. Callers that require an explicit check-and-set should use
// CheckAndPut.
Put(ctx context.Context, key string, totalSize int64, reader io.Reader) (version string, err error)
// CheckAndPut updates the blob keyed by |key| using a check-and-set on |expectedVersion|.

View File

@@ -425,8 +425,11 @@ func (gbs *GitBlobstore) Put(ctx context.Context, key string, totalSize int64, r
// Many NBS/table-file writes are content-addressed: if the key already exists, callers
// assume it refers to the same bytes and treat the operation as idempotent.
//
// The manifest is the main exception (it is mutable and updated via CheckAndPut), so
// we only apply this fast-path for non-manifest keys.
// GitBlobstore enforces that assumption by fast-succeeding when a non-manifest key
// already exists: it returns the existing per-key version and does not overwrite the
// key (and does not consume |reader|).
//
// The manifest is the main exception (it is mutable and updated via CheckAndPut).
if ver, ok, err := gbs.tryFastSucceedPutIfKeyExists(ctx, key); err != nil {
return "", err
} else if ok {