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(crit/stats): add const for dump and restore #93

Merged
merged 1 commit into from
Sep 6, 2022
Merged
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
9 changes: 7 additions & 2 deletions crit/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"github.com/checkpoint-restore/go-criu/v6/crit/images"
)

const (
StatsDump = "stats-dump"
StatsRestore = "stats-restore"
)

// Helper function to load stats file into Go struct
func getStats(path string) (*images.StatsEntry, error) {
c := New(path, "", "", false, false)
Expand All @@ -26,7 +31,7 @@ func getStats(path string) (*images.StatsEntry, error) {
// GetDumpStats returns the dump statistics of a checkpoint.
// dir is the path to the directory with the checkpoint images.
func GetDumpStats(dir string) (*images.DumpStatsEntry, error) {
stats, err := getStats(filepath.Join(dir, "stats-dump"))
stats, err := getStats(filepath.Join(dir, StatsDump))
if err != nil {
return nil, err
}
Expand All @@ -37,7 +42,7 @@ func GetDumpStats(dir string) (*images.DumpStatsEntry, error) {
// GetRestoreStats returns the restore statistics of a checkpoint.
// dir is the path to the directory with the checkpoint images.
func GetRestoreStats(dir string) (*images.RestoreStatsEntry, error) {
stats, err := getStats(filepath.Join(dir, "stats-restore"))
stats, err := getStats(filepath.Join(dir, StatsRestore))
if err != nil {
return nil, err
}
Expand Down