Skip to content

Commit

Permalink
Remove commit from getRecord since there's no repo history anymore (#423
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ericvolp12 authored Nov 8, 2023
2 parents 3f7c1d3 + 19866f4 commit d3d9ea3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
1 change: 1 addition & 0 deletions backfill/backfill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func TestBackfill(t *testing.T) {
ts := &testState{}

opts := backfill.DefaultBackfillOptions()
opts.CheckoutPath = "https://bsky.network/xrpc/com.atproto.sync.getRepo"
opts.NSIDFilter = "app.bsky.feed.follow/"

bf := backfill.NewBackfiller(
Expand Down
13 changes: 2 additions & 11 deletions bgs/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/labstack/echo/v4"
)

func (s *BGS) handleComAtprotoSyncGetRecord(ctx context.Context, collection string, commit string, did string, rkey string) (io.Reader, error) {
func (s *BGS) handleComAtprotoSyncGetRecord(ctx context.Context, collection string, did string, rkey string) (io.Reader, error) {
u, err := s.lookupUserByDid(ctx, did)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
Expand All @@ -40,16 +40,7 @@ func (s *BGS) handleComAtprotoSyncGetRecord(ctx context.Context, collection stri
return nil, fmt.Errorf("account was taken down")
}

reqCid := cid.Undef
if commit != "" {
reqCid, err = cid.Decode(commit)
if err != nil {
log.Errorw("failed to decode commit cid", "err", err, "cid", commit)
return nil, echo.NewHTTPError(http.StatusBadRequest, "failed to decode commit cid")
}
}

_, record, err := s.repoman.GetRecord(ctx, u.ID, collection, rkey, reqCid)
_, record, err := s.repoman.GetRecord(ctx, u.ID, collection, rkey, cid.Undef)
if err != nil {
if errors.Is(err, mst.ErrNotFound) {
return nil, echo.NewHTTPError(http.StatusNotFound, "record not found in repo")
Expand Down
10 changes: 1 addition & 9 deletions bgs/stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func (s *BGS) HandleComAtprotoSyncGetRecord(c echo.Context) error {
ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRecord")
defer span.End()
collection := c.QueryParam("collection")
commit := c.QueryParam("commit")
did := c.QueryParam("did")
rkey := c.QueryParam("rkey")

Expand All @@ -131,17 +130,10 @@ func (s *BGS) HandleComAtprotoSyncGetRecord(c echo.Context) error {
return c.JSON(http.StatusBadRequest, XRPCError{Message: fmt.Sprintf("invalid did: %s", did)})
}

if commit != "" {
_, err = cid.Parse(commit)
if err != nil {
return c.JSON(http.StatusBadRequest, XRPCError{Message: fmt.Sprintf("invalid commit: %s", commit)})
}
}

var out io.Reader
var handleErr error
// func (s *BGS) handleComAtprotoSyncGetRecord(ctx context.Context,collection string,commit string,did string,rkey string) (io.Reader, error)
out, handleErr = s.handleComAtprotoSyncGetRecord(ctx, collection, commit, did, rkey)
out, handleErr = s.handleComAtprotoSyncGetRecord(ctx, collection, did, rkey)
if handleErr != nil {
return handleErr
}
Expand Down

0 comments on commit d3d9ea3

Please sign in to comment.