MCPcopy Create free account
hub / github.com/blues/note / CheckpointNoteboxIfNeeded

Function CheckpointNoteboxIfNeeded

lib/notebox.go:327–349  ·  view source on GitHub ↗

CheckpointNoteboxIfNeeded checkpoints a notebox if it's open, purging closed files from the cache

(ctx context.Context, localEndpointID string, boxLocalStorage string)

Source from the content-addressed store, hash-verified

325
326// CheckpointNoteboxIfNeeded checkpoints a notebox if it's open, purging closed files from the cache
327func CheckpointNoteboxIfNeeded(ctx context.Context, localEndpointID string, boxLocalStorage string) error {
328 // Initialize debugging if we've not done so before
329 debugEnvInit()
330
331 var err error
332 var notebox *Notebox
333
334 // Reopen the notebox (and bump the refcount) if it's already open
335 boxLock.Lock()
336 boxi, present := openboxes.Load(boxLocalStorage)
337 if present && boxi.(*NoteboxInstance).endpointID == localEndpointID {
338 notebox, err = uReopenNotebox(ctx, localEndpointID, boxLocalStorage)
339 }
340 boxLock.Unlock()
341
342 if notebox == nil || err != nil {
343 return err
344 }
345
346 err = notebox.CheckpointPurge(ctx)
347 _ = notebox.Close(ctx)
348 return err
349}
350
351// Purge checkpoints all noteboxes and force a purge of notefiles
352func Purge(ctx context.Context) error {

Callers

nothing calls this directly

Calls 4

CheckpointPurgeMethod · 0.95
CloseMethod · 0.95
debugEnvInitFunction · 0.85
uReopenNoteboxFunction · 0.85

Tested by

no test coverage detected