this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

repo: return bytes and CID from GetRecordBytes

+6 -9
+4 -4
atproto/repo/repo.go
··· 48 48 return c, nil 49 49 } 50 50 51 - func (repo *Repo) GetRecordBytes(ctx context.Context, collection syntax.NSID, rkey syntax.RecordKey) ([]byte, error) { 51 + func (repo *Repo) GetRecordBytes(ctx context.Context, collection syntax.NSID, rkey syntax.RecordKey) ([]byte, *cid.Cid, error) { 52 52 c, err := repo.GetRecordCID(ctx, collection, rkey) 53 53 if err != nil { 54 - return nil, err 54 + return nil, nil, err 55 55 } 56 56 blk, err := repo.RecordStore.Get(ctx, *c) 57 57 if err != nil { 58 - return nil, err 58 + return nil, nil, err 59 59 } 60 60 // TODO: not verifying CID 61 - return blk.RawData(), nil 61 + return blk.RawData(), c, nil 62 62 } 63 63 64 64 // Snapshots the current state of the repository, resulting in a new (unsigned) `Commit` struct.
+2 -5
atproto/repo/sync.go
··· 61 61 if err != nil { 62 62 return nil, fmt.Errorf("invalid repo path in ops list: %w", err) 63 63 } 64 - val, err := repo.GetRecordCID(ctx, nsid, rkey) 64 + // don't use the returned bytes, but do actually read them out of store (not just CID) 65 + _, val, err := repo.GetRecordBytes(ctx, nsid, rkey) 65 66 if err != nil { 66 67 return nil, err 67 68 } 68 69 if *c != *val { 69 70 return nil, fmt.Errorf("record op doesn't match MST tree value") 70 - } 71 - _, err = repo.GetRecordBytes(ctx, nsid, rkey) 72 - if err != nil { 73 - return nil, err 74 71 } 75 72 } 76 73 }