MCPcopy
hub / github.com/perkeep/perkeep / indexReadyBlobs

Method indexReadyBlobs

pkg/index/receive.go:123–155  ·  view source on GitHub ↗

indexReadyBlobs indexes blobs that have been recently marked as ready to be reindexed, after the blobs they depend on eventually were indexed.

(ctx context.Context)

Source from the content-addressed store, hash-verified

121// indexReadyBlobs indexes blobs that have been recently marked as ready to be
122// reindexed, after the blobs they depend on eventually were indexed.
123func (ix *Index) indexReadyBlobs(ctx context.Context) {
124 defer ix.reindexWg.Done()
125
126 popReadyReindex := func() (blob.Ref, bool) {
127 ix.Lock()
128 defer ix.Unlock()
129
130 if len(ix.readyReindex) == 0 {
131 return blob.Ref{}, false
132 }
133 var br blob.Ref
134 for br = range ix.readyReindex {
135 break
136 }
137 delete(ix.readyReindex, br)
138
139 return br, true
140 }
141
142 failed := make(map[blob.Ref]bool)
143 for br, ok := popReadyReindex(); ok; br, ok = popReadyReindex() {
144 if err := ix.indexBlob(ctx, br); err != nil {
145 log.Printf("out-of-order indexBlob(%v) = %v", br, err)
146 failed[br] = true
147 }
148 }
149
150 ix.Lock()
151 defer ix.Unlock()
152 for br := range failed {
153 ix.readyReindex[br] = true
154 }
155}
156
157// noteBlobIndexed checks if the recent indexing of br now allows the blobs that
158// were depending on br, to be indexed in turn. If yes, they're reindexed

Callers 1

noteBlobIndexedMethod · 0.95

Calls 5

LockMethod · 0.95
UnlockMethod · 0.95
indexBlobMethod · 0.95
deleteFunction · 0.85
PrintfMethod · 0.80

Tested by

no test coverage detected