@@ -1021,8 +1021,8 @@ func (m *ExistingDataReplaceSelect) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
1021
1021
m .state .replaceExistingData = false
1022
1022
return m , tea .Quit
1023
1023
case ReplaceData :
1024
- // TODO: comet unsafe-reset-all here too
1025
1024
m .state .replaceExistingData = true
1025
+ // TODO: do the deletion confirmation
1026
1026
switch m .state .syncMethod {
1027
1027
case string (Snapshot ):
1028
1028
return NewSnapshotEndpointInput (m .state ), nil
@@ -1186,7 +1186,7 @@ type SnapshotExtractLoading struct {
1186
1186
1187
1187
func NewSnapshotExtractLoading (state * RunL1NodeState ) * SnapshotExtractLoading {
1188
1188
return & SnapshotExtractLoading {
1189
- Loading : utils .NewLoading ("Extracting downloaded snapshot..." , snapshotExtractor ()),
1189
+ Loading : utils .NewLoading ("Extracting downloaded snapshot..." , snapshotExtractor (state )),
1190
1190
state : state ,
1191
1191
}
1192
1192
}
@@ -1221,15 +1221,22 @@ func (m *SnapshotExtractLoading) View() string {
1221
1221
return m .state .weave .Render () + m .Loading .View ()
1222
1222
}
1223
1223
1224
- func snapshotExtractor () tea.Cmd {
1224
+ func snapshotExtractor (state * RunL1NodeState ) tea.Cmd {
1225
1225
return func () tea.Msg {
1226
1226
userHome , err := os .UserHomeDir ()
1227
1227
if err != nil {
1228
1228
return utils.ErrorLoading {Err : fmt .Errorf ("[error] Failed to get user home: %v" , err )}
1229
1229
}
1230
1230
1231
- targetDir := filepath .Join (userHome , utils .InitiaDirectory )
1232
- cmd := exec .Command ("bash" , "-c" , fmt .Sprintf ("lz4 -c -d %s | tar -x -C %s" , filepath .Join (userHome , utils .WeaveDataDirectory , utils .SnapshotFilename ), targetDir ))
1231
+ initiaHome := filepath .Join (userHome , utils .InitiaDirectory )
1232
+ binaryPath := filepath .Join (userHome , utils .WeaveDataDirectory , fmt .Sprintf ("initia@%s" , state .initiadVersion ), "initiad" )
1233
+
1234
+ runCmd := exec .Command (binaryPath , "comet" , "unsafe-reset-all" , "--keep-addr-book" , "--home" , initiaHome )
1235
+ if err := runCmd .Run (); err != nil {
1236
+ panic (fmt .Sprintf ("failed to run initiad comet unsafe-reset-all: %v" , err ))
1237
+ }
1238
+
1239
+ cmd := exec .Command ("bash" , "-c" , fmt .Sprintf ("lz4 -c -d %s | tar -x -C %s" , filepath .Join (userHome , utils .WeaveDataDirectory , utils .SnapshotFilename ), initiaHome ))
1233
1240
cmd .Stdout = os .Stdout
1234
1241
cmd .Stderr = os .Stderr
1235
1242
@@ -1309,6 +1316,14 @@ func setupStateSync(state *RunL1NodeState) tea.Cmd {
1309
1316
return utils.ErrorLoading {Err : fmt .Errorf ("[error] Failed to setup state sync trust_hash: %v" , err )}
1310
1317
}
1311
1318
1319
+ initiaHome := filepath .Join (userHome , utils .InitiaDirectory )
1320
+ binaryPath := filepath .Join (userHome , utils .WeaveDataDirectory , fmt .Sprintf ("initia@%s" , state .initiadVersion ), "initiad" )
1321
+
1322
+ runCmd := exec .Command (binaryPath , "comet" , "unsafe-reset-all" , "--keep-addr-book" , "--home" , initiaHome )
1323
+ if err := runCmd .Run (); err != nil {
1324
+ panic (fmt .Sprintf ("failed to run initiad comet unsafe-reset-all: %v" , err ))
1325
+ }
1326
+
1312
1327
return utils.EndLoading {}
1313
1328
}
1314
1329
}
0 commit comments