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

Function OpenEndpointNotebox

lib/notebox.go:145–166  ·  view source on GitHub ↗

OpenEndpointNotebox opens - creating if necessary - a notebox in File storage for an endpoint

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

Source from the content-addressed store, hash-verified

143
144// OpenEndpointNotebox opens - creating if necessary - a notebox in File storage for an endpoint
145func 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.
169func Delete(ctx context.Context, boxStorage string) (err error) {

Callers 3

openHubNoteboxForDeviceFunction · 0.85
testNoteboxFunction · 0.85

Calls 2

OpenNoteboxFunction · 0.85
CreateNoteboxFunction · 0.85

Tested by 2

testNoteboxFunction · 0.68