SetChunkProgress updates chunk progress array from external sources (e.g. remote events).
(progress []int64)
| 369 | |
| 370 | // SetChunkProgress updates chunk progress array from external sources (e.g. remote events). |
| 371 | func (ps *ProgressState) SetChunkProgress(progress []int64) { |
| 372 | ps.mu.Lock() |
| 373 | defer ps.mu.Unlock() |
| 374 | |
| 375 | if len(progress) == 0 { |
| 376 | return |
| 377 | } |
| 378 | if len(ps.ChunkProgress) != len(progress) { |
| 379 | ps.ChunkProgress = make([]int64, len(progress)) |
| 380 | } |
| 381 | copy(ps.ChunkProgress, progress) |
| 382 | } |
| 383 | |
| 384 | // SetChunkState sets the 2-bit state for a specific chunk index (thread-safe) |
| 385 | func (ps *ProgressState) SetChunkState(index int, status ChunkStatus) { |