A container registry that uses the AT Protocol for manifest storage and S3 for blob storage. atcr.io
docker container atproto go
80
fork

Configure Feed

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

attempt to fix car validation

+44 -11
+44 -11
pkg/hold/pds/xrpc.go
··· 7 7 "net/http" 8 8 "strings" 9 9 10 + "github.com/bluesky-social/indigo/repo" 11 + "github.com/bluesky-social/indigo/util" 10 12 "github.com/ipfs/go-cid" 11 13 "github.com/ipld/go-car" 12 14 carutil "github.com/ipld/go-car/util" ··· 273 275 return 274 276 } 275 277 276 - // Get the record CID and raw bytes 277 - recordCID, _, err := h.pds.GetCrewMember(r.Context(), rkey) 278 + // Get the current repo head 279 + repoHead, err := h.pds.carstore.GetUserRepoHead(r.Context(), h.pds.uid) 280 + if err != nil { 281 + http.Error(w, fmt.Sprintf("failed to get repo head: %v", err), http.StatusInternalServerError) 282 + return 283 + } 284 + 285 + // Create a new delta session with logging blockstore 286 + tempSession, err := h.pds.carstore.NewDeltaSession(r.Context(), h.pds.uid, nil) 287 + if err != nil { 288 + http.Error(w, fmt.Sprintf("failed to create temp session: %v", err), http.StatusInternalServerError) 289 + return 290 + } 291 + 292 + // Wrap the session's blockstore with a logging blockstore 293 + loggingBS := util.NewLoggingBstore(tempSession) 294 + 295 + // Open the repo with the logging blockstore 296 + tempRepo, err := repo.OpenRepo(r.Context(), loggingBS, repoHead) 278 297 if err != nil { 279 - http.Error(w, fmt.Sprintf("failed to get record: %v", err), http.StatusNotFound) 298 + http.Error(w, fmt.Sprintf("failed to open repo: %v", err), http.StatusInternalServerError) 280 299 return 281 300 } 282 301 283 - // Get the raw block from the blockstore 284 - blk, err := h.pds.repo.Blockstore().Get(r.Context(), recordCID) 302 + // Get the record path 303 + path := fmt.Sprintf("%s/%s", collection, rkey) 304 + 305 + // Get the record (this will log all accessed blocks in the MST path) 306 + recordCID, _, err := tempRepo.GetRecordBytes(r.Context(), path) 285 307 if err != nil { 286 - http.Error(w, fmt.Sprintf("failed to get record block: %v", err), http.StatusInternalServerError) 308 + http.Error(w, fmt.Sprintf("failed to get record: %v", err), http.StatusNotFound) 287 309 return 288 310 } 289 311 290 - // Write CAR file with the single record 312 + // Get all blocks that were accessed during record retrieval 313 + blocks := loggingBS.GetLoggedBlocks() 314 + 315 + // Log block count for debugging 316 + fmt.Printf("sync.getRecord: Retrieved %d blocks for record at %s/%s\n", len(blocks), collection, rkey) 317 + for i, blk := range blocks { 318 + fmt.Printf(" Block %d: CID=%s, size=%d bytes\n", i+1, blk.Cid().String(), len(blk.RawData())) 319 + } 320 + 321 + // Write CAR file with all accessed blocks 291 322 w.Header().Set("Content-Type", "application/vnd.ipld.car") 292 323 293 324 // Create a buffer to write the CAR data ··· 305 336 return 306 337 } 307 338 308 - // Write the block using LdWrite 309 - if err := carutil.LdWrite(&buf, recordCID.Bytes(), blk.RawData()); err != nil { 310 - http.Error(w, fmt.Sprintf("failed to write block to CAR: %v", err), http.StatusInternalServerError) 311 - return 339 + // Write all logged blocks to the CAR file 340 + for _, blk := range blocks { 341 + if err := carutil.LdWrite(&buf, blk.Cid().Bytes(), blk.RawData()); err != nil { 342 + http.Error(w, fmt.Sprintf("failed to write block to CAR: %v", err), http.StatusInternalServerError) 343 + return 344 + } 312 345 } 313 346 314 347 // Write the CAR data to the response