Skip to content

Commit 5472fb5

Browse files
mergify[bot]yihuangtac0turtlejulienrbrt
authored
fix: snapshot commands panic if snapshot don't exists (backport cosmos#16138) (cosmos#16140)
Co-authored-by: yihuang <[email protected]> Co-authored-by: marbar3778 <[email protected]> Co-authored-by: Julien Robert <[email protected]>
1 parent 10cc30f commit 5472fb5

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dist
2323
tools-stamp
2424
buf-stamp
2525
artifacts
26+
tools/
2627

2728
# Data - ideally these don't exist
2829
baseapp/data/*

client/snapshot/dump.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package snapshot
33
import (
44
"archive/tar"
55
"compress/gzip"
6+
"errors"
67
"fmt"
78
"io"
89
"os"
@@ -48,6 +49,10 @@ func DumpArchiveCmd() *cobra.Command {
4849
return err
4950
}
5051

52+
if snapshot == nil {
53+
return errors.New("snapshot doesn't exist")
54+
}
55+
5156
bz, err := snapshot.Marshal()
5257
if err != nil {
5358
return err

snapshots/manager.go

+4
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ func (m *Manager) RestoreLocalSnapshot(height uint64, format uint32) error {
398398
return err
399399
}
400400

401+
if snapshot == nil {
402+
return fmt.Errorf("snapshot doesn't exist, height: %d, format: %d", height, format)
403+
}
404+
401405
m.mtx.Lock()
402406
defer m.mtx.Unlock()
403407

0 commit comments

Comments
 (0)