Initialize notebox storage
(ctx context.Context, endpointID string, boxStorage string, storage storage)
| 83 | |
| 84 | // Initialize notebox storage |
| 85 | func 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 |
| 120 | func CreateNotebox(ctx context.Context, endpointID string, boxStorage string) (err error) { |
no test coverage detected