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

Function initNotebox

lib/notebox.go:85–117  ·  view source on GitHub ↗

Initialize notebox storage

(ctx context.Context, endpointID string, boxStorage string, storage storage)

Source from the content-addressed store, hash-verified

83
84// Initialize notebox storage
85func initNotebox(ctx context.Context, endpointID string, boxStorage string, storage storage) (err error) {
86 // Create the notefile for the notebox
87 boxfile := CreateNotefile(false)
88
89 // Create the note for managing the notebox's notefile, whose ID is the endpoint itself
90 body := noteboxBody{}
91 // Removed 2017-11-27 because not only is this not needed, but it is also potentially
92 // a security issue if it were present and used, because the client could cause the
93 // service to fetch the notebox from elsewhere.
94 if false {
95 body.Notefile.Storage = boxStorage
96 }
97 note, err := note.CreateNote(noteboxBodyToJSON(body), nil)
98 if err == nil {
99 _, err = boxfile.AddNote(ctx, nil, endpointID, compositeNoteID(endpointID, endpointID), note)
100 }
101 if err != nil {
102 return err
103 }
104
105 // Write the storage object. No lock isneeded because we just created it
106 err = storage.writeNotefile(ctx, boxfile, boxStorage, boxStorage)
107 if err != nil {
108 return err
109 }
110
111 if debugBox {
112 logDebug(ctx, "%s created", boxStorage)
113 }
114
115 // Done
116 return nil
117}
118
119// CreateNotebox creates a notebox on this endpoint
120func CreateNotebox(ctx context.Context, endpointID string, boxStorage string) (err error) {

Callers 1

CreateNoteboxFunction · 0.85

Calls 6

CreateNotefileFunction · 0.85
noteboxBodyToJSONFunction · 0.85
compositeNoteIDFunction · 0.85
logDebugFunction · 0.85
writeNotefileMethod · 0.80
AddNoteMethod · 0.45

Tested by

no test coverage detected