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

Function openHubNoteboxForDevice

lib/hubreq.go:439–476  ·  view source on GitHub ↗

Open the endpoint's notebox

(ctx context.Context, session *HubSession, deviceUID string, deviceSN string, productUID string, endpointID string, event EventFunc)

Source from the content-addressed store, hash-verified

437
438// Open the endpoint's notebox
439func openHubNoteboxForDevice(ctx context.Context, session *HubSession, deviceUID string, deviceSN string, productUID string, endpointID string, event EventFunc) (box *Notebox, ei *NotefileEventInfo, appUID string, err error) {
440 timerName := timerBegin(ctx, "openNoteboxForDevice")
441 defer timerEnd(ctx, timerName)
442
443 // Warn if this take too long; it should be a few milliseconds
444 start := time.Now()
445 defer func() {
446 if time.Since(start) > time.Second {
447 session.LogWarn(ctx, "[timewarn] excessively long time to open the notebox: %s", time.Since(start))
448 }
449 }()
450
451 // Ensure that hub endpoint is available
452 var hubEndpointID, deviceStorageObject string
453 timerName = timerBegin(ctx, "hubDiscover")
454 hubEndpointID, appUID, deviceStorageObject, err = HubDiscover(deviceUID, deviceSN, productUID, appUID)
455 timerEnd(ctx, timerName)
456 if err != nil {
457 return
458 }
459
460 // Open the endpoint's box on behalf of the Notehub, because we can't open it directly under the device endpoint IDs
461 timerName = timerBegin(ctx, "openNotebox`")
462 box, err = OpenEndpointNotebox(ctx, hubEndpointID, deviceStorageObject, true)
463 timerEnd(ctx, timerName)
464 if err != nil {
465 return
466 }
467
468 // Set the default notification context for files opened within this box instance
469 ei = EventInfo(deviceUID, deviceSN, productUID, appUID, session.Session.Transport, event, session)
470
471 // If we haven't yet enum'ed the notefiles, do so
472 sawNotefile(session, box, "")
473
474 // Done
475 return
476}
477
478// Ensure that the specified notefile is in the list
479func sawNotefile(session *HubSession, box *Notebox, notefileID string) {

Callers 13

hubNoteboxChangesFunction · 0.85
hubNoteboxMergeFunction · 0.85
hubNotefileChangesFunction · 0.85
hubNotefileMergeFunction · 0.85
hubNotefilesMergeFunction · 0.85
hubNoteboxSummaryFunction · 0.85
hubNotefileAddNoteFunction · 0.85
hubNotefileDeleteNoteFunction · 0.85
hubNotefileUpdateNoteFunction · 0.85
hubReadFileFunction · 0.85

Calls 7

timerBeginFunction · 0.85
timerEndFunction · 0.85
HubDiscoverFunction · 0.85
OpenEndpointNoteboxFunction · 0.85
EventInfoFunction · 0.85
sawNotefileFunction · 0.85
LogWarnMethod · 0.80

Tested by

no test coverage detected