Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: snapshot commands panic if snapshot don't exists (backport #16138) #16140

Merged
merged 4 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dist
tools-stamp
buf-stamp
artifacts
tools/

# Data - ideally these don't exist
baseapp/data/*
Expand Down
5 changes: 5 additions & 0 deletions client/snapshot/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package snapshot
import (
"archive/tar"
"compress/gzip"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -48,6 +49,10 @@ func DumpArchiveCmd() *cobra.Command {
return err
}

if snapshot == nil {
return errors.New("snapshot doesn't exist")
}

bz, err := snapshot.Marshal()
if err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions snapshots/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ func (m *Manager) RestoreLocalSnapshot(height uint64, format uint32) error {
return err
}

if snapshot == nil {
return fmt.Errorf("snapshot doesn't exist, height: %d, format: %d", height, format)
}

m.mtx.Lock()
defer m.mtx.Unlock()

Expand Down