fix: save history
This commit is contained in:
@@ -77,6 +77,7 @@ func Load() *Config {
|
||||
}
|
||||
v.SetDefault("host_name", defaultHostName)
|
||||
v.SetDefault("id", uuid.New().String())
|
||||
v.SetDefault("save_history", true)
|
||||
|
||||
v.SetConfigFile(configFile)
|
||||
v.SetConfigType("json")
|
||||
@@ -182,3 +183,16 @@ func (c *Config) GetSaveHistory() bool {
|
||||
func (c *Config) GetVersion() string {
|
||||
return Version
|
||||
}
|
||||
|
||||
func (c *Config) SetWindowState(state WindowState) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
c.WindowState = state
|
||||
c.v.Set("window_state", state)
|
||||
}
|
||||
|
||||
func (c *Config) GetWindowState() WindowState {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
return c.WindowState
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func (s *Service) SaveHistory() {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
file, err := os.OpenFile(historyPath, os.O_CREATE|os.O_RDWR, os.FileMode(0644))
|
||||
file, err := os.OpenFile(historyPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func (s *Service) Start() {
|
||||
}
|
||||
|
||||
func (s *Service) GetTransferList() []*Transfer {
|
||||
var requests []*Transfer
|
||||
var requests []*Transfer = make([]*Transfer, 0)
|
||||
s.transferList.Range(func(key, value any) bool {
|
||||
requests = append(requests, value.(*Transfer))
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user