Skip to content

Commit 7c18606

Browse files
committed
save performance profile to local state
1 parent 0c19682 commit 7c18606

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

local_state.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,31 @@ func (self *LocalState) GetProvideControlMode() ProvideControlMode {
409409
return ProvideControlModeAuto
410410
}
411411

412+
func (self *LocalState) SetPerformanceProfile(profile *PerformanceProfile) error {
413+
path := filepath.Join(self.localStorageDir, ".performance_profile")
414+
if profile == nil {
415+
os.Remove(path)
416+
return nil
417+
} else {
418+
profileBytes, err := json.Marshal(profile)
419+
if err != nil {
420+
return err
421+
}
422+
return os.WriteFile(path, profileBytes, LocalStorageFilePermissions)
423+
}
424+
}
425+
426+
func (self *LocalState) GetPerformanceProfile() *PerformanceProfile {
427+
path := filepath.Join(self.localStorageDir, ".performance_profile")
428+
if performanceProfileBytes, err := os.ReadFile(path); err == nil {
429+
var performanceProfile PerformanceProfile
430+
if err := json.Unmarshal(performanceProfileBytes, &performanceProfile); err == nil {
431+
return &performanceProfile
432+
}
433+
}
434+
return nil
435+
}
436+
412437
func (self *LocalState) SetAllowForeground(allowForeground bool) error {
413438
path := filepath.Join(self.localStorageDir, ".allow_foreground")
414439
allowForegroundBytes, err := json.Marshal(allowForeground)

sdk-js/package-lock.json

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)