addBlobToCopy adds a blob to copy to memory (not to disk: that's enqueue). It returns true if it was added, or false if it was a duplicate.
(sb blob.SizedRef)
| 686 | // addBlobToCopy adds a blob to copy to memory (not to disk: that's enqueue). |
| 687 | // It returns true if it was added, or false if it was a duplicate. |
| 688 | func (sh *SyncHandler) addBlobToCopy(sb blob.SizedRef) bool { |
| 689 | sh.mu.Lock() |
| 690 | defer sh.mu.Unlock() |
| 691 | if _, dup := sh.needCopy[sb.Ref]; dup { |
| 692 | return false |
| 693 | } |
| 694 | |
| 695 | sh.needCopy[sb.Ref] = sb.Size |
| 696 | sh.bytesRemain += int64(sb.Size) |
| 697 | |
| 698 | // Non-blocking send to wake up looping goroutine if it's |
| 699 | // sleeping... |
| 700 | select { |
| 701 | case sh.wakec <- true: |
| 702 | default: |
| 703 | } |
| 704 | return true |
| 705 | } |
| 706 | |
| 707 | func (sh *SyncHandler) enqueue(sb blob.SizedRef) error { |
| 708 | if !sh.addBlobToCopy(sb) { |
no test coverage detected