CheckpointNoteboxIfNeeded checkpoints a notebox if it's open, purging closed files from the cache
(ctx context.Context, localEndpointID string, boxLocalStorage string)
| 325 | |
| 326 | // CheckpointNoteboxIfNeeded checkpoints a notebox if it's open, purging closed files from the cache |
| 327 | func 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 |
| 352 | func Purge(ctx context.Context) error { |
nothing calls this directly
no test coverage detected