Skip to content

Commit 559e75e

Browse files
committed
Do not write version until migration successful
1 parent 795e3b0 commit 559e75e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ipfs-10-to-11/migration/migration.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,21 @@ func (m Migration) Apply(opts migrate.Options) error {
4848
return err
4949
}
5050

51-
// Write new version before opening repo, so that opening the repo does not
52-
// result in an error stating the repo needs a migration (since this is the
53-
// migration).
54-
err = mfsr.RepoPath(opts.Path).WriteVersion("11")
55-
if err != nil {
56-
log.Error("failed to update version file to 11")
57-
return err
58-
}
51+
// Set to previous version to avoid "needs migration" error. This is safe
52+
// for this migration since repo has not changed.
53+
fsrepo.RepoVersion = 10
5954

6055
if err = transferPins(opts.Path); err != nil {
6156
log.Error("failed to transfer pins:", err.Error())
6257
return err
6358
}
6459

60+
err = mfsr.RepoPath(opts.Path).WriteVersion("11")
61+
if err != nil {
62+
log.Error("failed to update version file to 11")
63+
return err
64+
}
65+
6566
log.Log("updated version file")
6667
return nil
6768
}

0 commit comments

Comments
 (0)