Delete deletes a closed Notebox, and releases its storage.
(ctx context.Context, boxStorage string)
| 167 | |
| 168 | // Delete deletes a closed Notebox, and releases its storage. |
| 169 | func 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 |
| 197 | func uReopenNotebox(ctx context.Context, localEndpointID string, boxLocalStorage string) (notebox *Notebox, err error) { |
nothing calls this directly
no test coverage detected