Skip to content

Commit

Permalink
Merge pull request #93 from snprajwal/stats-const
Browse files Browse the repository at this point in the history
fix(crit/stats): add const for dump and restore
  • Loading branch information
rst0git authored Sep 6, 2022
2 parents c54aaf7 + be1c695 commit 74ddb08
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 74ddb08

Please sign in to comment.