Пример #1
0
 function pollUpdates (_G) {
   _G.playbackLog.log('start polling')
   sync.fetchConfiguration(_G, (err, code) => {
     if (err) {
       _G.playbackLog.log('poll errored')
     }
     _G.playbackLog.log('fetchConfiguration returned with: ' + code)
     if (code === _G.codes.CONFIGURATION_UPDATED) {
       setTimeout(
         () => {
           app.relaunch()
           app.quit()
         }, 1
       )
       fs.readFile(_G.confFilePath, (err, configuration) => {
         if (err) { _G.playbackLog.log('read conf errored') }
         playConfiguration(_G, JSON.parse(configuration))
       })
     }
     // console.log('poll finished')
     setTimeout(function () {
       pollUpdates(_G)
     }, 30e3)
   })
 }
Пример #2
0
 fs.access(_G.tempConfFilePath, fs.F_OK, (err) => {
   if (!err) { // Metafile download in progress
     setTimeout(() => { readConfiguration(_G, callback) }, 1e3) // retry in a sec
     return callback(_G.codes.CONFIGURATION_DOWNLOAD_IN_PROGRESS)
   }
   sync.fetchConfiguration(_G, (error, code, configuration) => {
     if (error) {
       _G.playbackLog.log(error.toJSON().statusCode)
       setTimeout(() => { readConfiguration(_G, callback) }, 30e3) // retry in 30sec
       return callback(error.toJSON().statusCode)
     }
     // Got positive result from fetchConfiguration
     return callback(code, configuration)
   })
   return callback(_G.codes.CONFIGURATION_FILE_NOT_PRESENT)
 })