File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -327,10 +327,30 @@ func (n *Core) connect() error {
327327}
328328
329329func (n * Core ) mediaEvents (ctx context.Context , storage string ) {
330+ defer func () {
331+ n .logger .Warn ().WithField ("storage" , storage ).Log ("Disconnected from event source" )
332+ }()
333+
330334 m := & Media {}
331335
332336 for {
333- ch , err := n .client .MediaEvents (ctx , storage , "/**" )
337+ select {
338+ case <- ctx .Done ():
339+ return
340+ default :
341+ }
342+
343+ n .lock .RLock ()
344+ client := n .client
345+ n .lock .RUnlock ()
346+
347+ if client == nil {
348+ n .logger .Error ().WithField ("storage" , storage ).Log ("Failed to connect to event source, client not connected" )
349+ time .Sleep (5 * time .Second )
350+ continue
351+ }
352+
353+ ch , err := client .MediaEvents (ctx , storage , "/**" )
334354 if err != nil {
335355 m .available = false
336356 m .media = map [string ]int64 {}
You can’t perform that action at this time.
0 commit comments