diff --git a/carstore/bs.go b/carstore/bs.go index 7feb9d697..a992a2776 100644 --- a/carstore/bs.go +++ b/carstore/bs.go @@ -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) { @@ -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) { diff --git a/cmd/gosky/sync.go b/cmd/gosky/sync.go index f27c8b1af..6304205da 100644 --- a/cmd/gosky/sync.go +++ b/cmd/gosky/sync.go @@ -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: ` []`, + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "host", + }, + }, Action: func(cctx *cli.Context) error { ctx := context.Background() arg := cctx.Args().First() @@ -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 { diff --git a/repomgr/repomgr.go b/repomgr/repomgr.go index 77fb5adf6..14e61f6bc 100644 --- a/repomgr/repomgr.go +++ b/repomgr/repomgr.go @@ -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")