Skip to content

Commit e2c30d3

Browse files
committed
check storage ID first
1 parent 565251d commit e2c30d3

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

cmd/curio/storacha-migration.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,19 @@ var importPiecesCmd = &cli.Command{
126126
return xerrors.Errorf("resolving target path: %w", err)
127127
}
128128

129+
storageID, err := pieceStorageID(targetPath)
130+
if err != nil {
131+
return xerrors.Errorf("getting storage ID: %w", err)
132+
}
133+
129134
db, err := deps.MakeDB(cctx)
130135
if err != nil {
131136
return err
132137
}
133138

134139
si := paths.NewDBIndex(curioalerting.NewAlertingSystem(), db)
135140

136-
out, err := runImportPieces(ctx, db, si, sourcePath, targetPath, cctx.Int("batch-size"))
141+
out, err := runImportPieces(ctx, db, si, storageID, sourcePath, targetPath, cctx.Int("batch-size"))
137142
if err != nil {
138143
return err
139144
}
@@ -147,14 +152,9 @@ var importPiecesCmd = &cli.Command{
147152
},
148153
}
149154

150-
func runImportPieces(ctx context.Context, db *harmonydb.DB, si paths.SectorIndex, sourcePath, targetPath string, batchSize int) (importPiecesOutput, error) {
155+
func runImportPieces(ctx context.Context, db *harmonydb.DB, si paths.SectorIndex, storageID storiface.ID, sourcePath, targetPath string, batchSize int) (importPiecesOutput, error) {
151156
var out importPiecesOutput
152157

153-
storageID, err := pieceStorageID(targetPath)
154-
if err != nil {
155-
return out, err
156-
}
157-
158158
staging := filepath.Join(targetPath, "storacha-staging")
159159
existing, err := os.ReadDir(staging)
160160
if err != nil {

0 commit comments

Comments
 (0)