diff --git a/repo/object/object_manager_test.go b/repo/object/object_manager_test.go index f728dafab..6d6e71bb5 100644 --- a/repo/object/object_manager_test.go +++ b/repo/object/object_manager_test.go @@ -146,8 +146,14 @@ func TestWriterCompleteChunkInTwoWrites(t *testing.T) { } func verifyIndirectBlock(ctx context.Context, t *testing.T, r *Manager, oid ID) { - for indexBlobID, isIndirect := oid.IndexObjectID(); isIndirect; indexBlobID, isIndirect = indexBlobID.IndexObjectID() { - rd, err := r.Open(ctx, indexBlobID) + for indexContentID, isIndirect := oid.IndexObjectID(); isIndirect; indexContentID, isIndirect = indexContentID.IndexObjectID() { + if c, _, ok := indexContentID.ContentID(); ok { + if !c.HasPrefix() { + t.Errorf("expected base content ID to be prefixed, was %v", c) + } + } + + rd, err := r.Open(ctx, indexContentID) if err != nil { t.Errorf("unable to open %v: %v", oid.String(), err) return diff --git a/repo/object/object_writer.go b/repo/object/object_writer.go index af8cf6f77..d57cdac35 100644 --- a/repo/object/object_writer.go +++ b/repo/object/object_writer.go @@ -18,6 +18,8 @@ var log = logging.GetContextLoggerFunc("object") +const indirectContentPrefix = "x" + // Writer allows writing content to the storage and supports automatic deduplication and encryption // of written data. type Writer interface { @@ -250,6 +252,11 @@ func (w *objectWriter) Result() (ID, error) { prefix: w.prefix, } + if iw.prefix == "" { + // force a prefix for indirect contents to make sure they get packaged into metadata (q) blobs. + iw.prefix = indirectContentPrefix + } + iw.initBuffer() defer iw.Close() //nolint:errcheck