function download() {
    var urls = settings.urls.slice(0);

    function tryNext() {
      var sourceUrl = urls.shift();
      if (!sourceUrl) {
        throw new Error('No valid url specified.');
      }

      logger.log('Attempting to transfer from ' + sourceUrl);

      return downloadSingle(sourceUrl)['catch'](function (err) {
        if (err.message === 'ENOTFOUND') {
          return tryNext();
        }
        throw err;
      });
    }

    return tryNext();
  }
//Attempts to download each url in turn until one is successful
Attempts to download each url in turn until one is successful
Attempts to download each url in turn until one is successful
function download() {
    var urls = settings.urls.slice(0);
    function tryNext() {
      var sourceUrl = urls.shift();
      if (!sourceUrl) {
        throw new Error('No valid url specified.');
      }
      logger.log('Attempting to transfer from ' + sourceUrl);
      return downloadSingle(sourceUrl)['catch'](function (err) {
        if (err.message === 'ENOTFOUND') {
          return tryNext();
        }
        throw err;
      });
    }
    return tryNext();
  }
function download ( ) { var urls = settings . urls . slice ( 0 ) ; function tryNext ( ) { var sourceUrl = urls . shift ( ) ; if ( ! sourceUrl ) { throw new Error ( 'No valid url specified.' ) ; } logger . log ( 'Attempting to transfer from ' + sourceUrl ) ; return downloadSingle ( sourceUrl ) [ 'catch' ] ( function ( err ) { if ( err . message === 'ENOTFOUND' ) { return tryNext ( ) ; } throw err ; } ) ; } return tryNext ( ) ; }
Attempts to download each url in turn until one is successful
Attempts to download each url in turn until one is successful