OpenEndpointNotebox opens - creating if necessary - a notebox in File storage for an endpoint
(ctx context.Context, localEndpointID string, boxLocalStorage string, create bool)
| 143 | |
| 144 | // OpenEndpointNotebox opens - creating if necessary - a notebox in File storage for an endpoint |
| 145 | func OpenEndpointNotebox(ctx context.Context, localEndpointID string, boxLocalStorage string, create bool) (box *Notebox, err error) { |
| 146 | // Open the notebox |
| 147 | box, err = OpenNotebox(ctx, localEndpointID, boxLocalStorage) |
| 148 | |
| 149 | // If error, assume that it doesn't exist, so create it and try again |
| 150 | if err != nil && create { |
| 151 | |
| 152 | err = CreateNotebox(ctx, localEndpointID, boxLocalStorage) |
| 153 | if err != nil { |
| 154 | return &Notebox{}, err |
| 155 | } |
| 156 | |
| 157 | box, err = OpenNotebox(ctx, localEndpointID, boxLocalStorage) |
| 158 | if err != nil { |
| 159 | return &Notebox{}, err |
| 160 | } |
| 161 | |
| 162 | } |
| 163 | |
| 164 | // Done |
| 165 | return box, err |
| 166 | } |
| 167 | |
| 168 | // Delete deletes a closed Notebox, and releases its storage. |
| 169 | func Delete(ctx context.Context, boxStorage string) (err error) { |