Save 保存到本地磁盘
()
| 288 | |
| 289 | // Save 保存到本地磁盘 |
| 290 | func (this *BandwidthStatManager) Save() error { |
| 291 | this.locker.Lock() |
| 292 | defer this.locker.Unlock() |
| 293 | |
| 294 | if len(this.m) == 0 { |
| 295 | return nil |
| 296 | } |
| 297 | |
| 298 | data, err := json.Marshal(this.m) |
| 299 | if err != nil { |
| 300 | return err |
| 301 | } |
| 302 | |
| 303 | _ = os.Remove(this.cacheFile) |
| 304 | return os.WriteFile(this.cacheFile, data, 0666) |
| 305 | } |
| 306 | |
| 307 | // Cancel 取消上传 |
| 308 | func (this *BandwidthStatManager) Cancel() { |