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

Function Delete

lib/notebox.go:169–194  ·  view source on GitHub ↗

Delete deletes a closed Notebox, and releases its storage.

(ctx context.Context, boxStorage string)

Source from the content-addressed store, hash-verified

167
168// Delete deletes a closed Notebox, and releases its storage.
169func Delete(ctx context.Context, boxStorage string) (err error) {
170
171 // First, checkpoint this notebox, with purge
172 box := &Notebox{}
173 boxi, present := openboxes.Load(boxStorage)
174 if !present {
175 return fmt.Errorf("notebox isn't open")
176 }
177 box.instance = boxi.(*NoteboxInstance)
178 _, _ = box.checkpoint(ctx, true, true, false, false)
179
180 // See if it's still around
181 _, present = openboxes.Load(boxStorage)
182 if present {
183 return fmt.Errorf(note.ErrNotefileInUse+" cannot delete an open notebox: %s", boxStorage)
184 }
185
186 // Get the storage class
187 storage, err := storageProvider(boxStorage)
188 if err != nil {
189 return err
190 }
191
192 // Delete the storage object
193 return storage.delete(ctx, boxStorage, boxStorage)
194}
195
196// reopenNotebox reopens it if it's already open
197func uReopenNotebox(ctx context.Context, localEndpointID string, boxLocalStorage string) (notebox *Notebox, err error) {

Callers

nothing calls this directly

Calls 3

checkpointMethod · 0.95
storageProviderFunction · 0.85
deleteMethod · 0.80

Tested by

no test coverage detected