MCPcopy
hub / github.com/perkeep/perkeep / addBlobToCopy

Method addBlobToCopy

pkg/server/sync.go:688–705  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
688func (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
707func (sh *SyncHandler) enqueue(sb blob.SizedRef) error {
708 if !sh.addBlobToCopy(sb) {

Callers 2

readQueueToMemoryMethod · 0.95
enqueueMethod · 0.95

Calls 2

LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected