Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't diff against existing data if performing a resync #432

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions carstore/bs.go
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ func BlockDiff(ctx context.Context, bs blockstore.Blockstore, oldroot cid.Cid, n
keepset[c] = true
oblk, err := bs.Get(ctx, c)
if err != nil {
return nil, err
return nil, fmt.Errorf("get failed in new tree: %w", err)
}

if err := cbg.ScanForLinks(bytes.NewReader(oblk.RawData()), func(lnk cid.Cid) {
Expand All @@ -901,7 +901,7 @@ func BlockDiff(ctx context.Context, bs blockstore.Blockstore, oldroot cid.Cid, n

oblk, err := bs.Get(ctx, c)
if err != nil {
return nil, err
return nil, fmt.Errorf("get failed in old tree: %w", err)
}

if err := cbg.ScanForLinks(bytes.NewReader(oblk.RawData()), func(lnk cid.Cid) {
Expand Down
9 changes: 9 additions & 0 deletions cmd/gosky/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ var syncGetRepoCmd = &cli.Command{
Name: "get-repo",
Usage: "download repo from account's PDS to local file (or '-' for stdout). for hex combine with 'xxd -ps -u -c 0'",
ArgsUsage: `<at-identifier> [<car-file-path>]`,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "host",
},
},
Action: func(cctx *cli.Context) error {
ctx := context.Background()
arg := cctx.Args().First()
Expand Down Expand Up @@ -57,6 +62,10 @@ var syncGetRepoCmd = &cli.Command{
return fmt.Errorf("no PDS endpoint for identity")
}

if h := cctx.String("host"); h != "" {
xrpcc.Host = h
}

log.Infof("downloading from %s to: %s", xrpcc.Host, carPath)
repoBytes, err := comatproto.SyncGetRepo(ctx, xrpcc, ident.DID.String(), "")
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions repomgr/repomgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,12 @@ func (rm *RepoManager) ImportNewRepo(ctx context.Context, user models.Uid, repoD
return err
}

if rev == nil {
// if 'rev' is nil, this implies a fresh sync.
// in this case, ignore any existing blocks we have and treat this like a clean import.
curhead = cid.Undef
}

if rev != nil && *rev != currev {
// TODO: we could probably just deal with this
return fmt.Errorf("ImportNewRepo called with incorrect base")
Expand Down
Loading