Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(function (infoCmdOutput) {
var items = {}
infoCmdOutput.split('\n')
.filter(function(str) {return str.indexOf(':') > 0})
.map(function(str) {return str.trim().split(':')})
.map(function(item) {items[item[0]] = item[1]})
var serverInfo = new ServerInfo()
try {
serverInfo.memoryBytes = parseInt(items['used_memory'], 10)
serverInfo.memoryRssBytes = parseInt(items['used_memory_rss'], 10)
serverInfo.evictedKeys = parseInt(items['evicted_keys'], 10)
serverInfo.numOfConnections = parseInt(items['connected_clients'], 10)
// The db0 key's value is something like: 'keys=12,expires=20'
serverInfo.numOfKeys = parseInt(items['db0'].split(',')[0].split('=')[1], 10)
} catch (e) {
Q.reject(new Error('Malformatted output from the "INFO" command of Redis'))
}
return Q.resolve(serverInfo)
})
}
return self.logDone(timeStart);
});
}
// Reset the status buffer
self.sStatusBuffer = '';
}
});
// Define the tracklist
self.tracklist = [];
// Start tracklist promise as rejected, so requestors do not wait for it if not immediately available.
// This is okay because no part of Volumio requires a populated tracklist to function.
self.tracklistReadyDeferred = null;
self.tracklistReady = libQ.reject('Tracklist not yet populated.');
// Attempt to load tracklist from database on disk
// TODO make this a relative path
self.sTracklistPath = __dirname + '/db/tracklist';
self.loadTracklistFromDB()
.fail(libFast.bind(self.pushError, self));
exec("spopd -c /etc/spopd.conf", function (error, stdout, stderr) {
if (error !== null) {
self.commandRouter.pushConsoleMessage('The following error occurred while starting SPOPD: ' + error);
}
else {
self.commandRouter.pushConsoleMessage('SpopD Daemon Started');
}
return self.logDone(timeStart);
});
}
// Reset the status buffer
self.sStatusBuffer = '';
}
});
// Define the tracklist
self.tracklist = [];
// Start tracklist promise as rejected, so requestors do not wait for it if not immediately available.
// This is okay because no part of Volumio requires a populated tracklist to function.
self.tracklistReadyDeferred = null;
self.tracklistReady = libQ.reject('Tracklist not yet populated.');
// Attempt to load tracklist from database on disk
// TODO make this a relative path
self.sTracklistPath = __dirname + '/db/tracklist';
self.loadTracklistFromDB()
.fail(libFast.bind(self.pushError, self));
exec("spopd -c /etc/spopd.conf", function (error, stdout, stderr) {
if (error !== null) {
self.commandRouter.pushConsoleMessage('The following error occurred while starting SPOPD: ' + error);
}
else {
self.commandRouter.pushConsoleMessage('SpopD Daemon Started');
}
ControllerMpd.prototype.haltIfNewerUpdateRunning = function (data, timeCurrentThread) {
var self = this;
self.commandRouter.pushConsoleMessage('ControllerMpd::haltIfNewerUpdateRunning');
if (self.timeLatestUpdate > timeCurrentThread) {
return libQ.reject('Alert: Aborting status update - newer one detected');
} else {
return libQ.resolve(data);
}
};
FakeCache.prototype._fakeFail = function (op) {
this._failureCount -= 1
var failure
if (this._nextFailure) {
if (this._nextFailure instanceof TimeoutError) this._getTimeoutCounter(op).inc()
failure = this._nextFailure
this._nextFailure = null
} else {
failure = new Error('Fake Error')
}
return Q.reject(failure)
}
artist: {[Sequelize.Op.eq]: uriInfo.parts[0]},
album: {[Sequelize.Op.eq]: uriInfo.parts[1]}
},
order: ['disk', 'tracknumber', 'title'],
raw: true
});
} else if (uriInfo.parts.length == 1) {
promise = this.library.searchTracks({
where: {
artist: {[Sequelize.Op.eq]: uriInfo.parts[0]},
},
order: ['disk', 'tracknumber', 'title'],
raw: true
});
} else {
return libQ.reject('DBImplementation.explodeArtistsUri: empty uri');
}
return promise.then(function(tracks) {
return tracks.map(self.track2mpd.bind(self));
});
};
var promise;
switch (uriInfo.protocol) {
case PROTOCOL_LIBRARY:
promise = self.handleLibraryUri(uri);
break;
case PROTOCOL_ARTISTS:
promise = self.handleArtistsUri(uri);
break;
case PROTOCOL_ALBUMS:
promise = self.handleAlbumsUri(uri);
break;
case PROTOCOL_GENRES:
promise = self.handleGenresUri(uri);
break;
default:
promise = libQ.reject('Unknown protocol: ' + uriInfo.protocol);
}
return promise;
}).then(function(response) {
response.navigation.prev.uri = previousUri || response.navigation.prev.uri || DBImplementation.getParentUri(uriInfo);
ControllerMpd.prototype.haltIfNewerUpdateRunning = function(data, timeCurrentThread) {
var self = this;
self.commandRouter.pushConsoleMessage('[' + Date.now() + '] ' + 'ControllerMpd::haltIfNewerUpdateRunning');
if (self.timeLatestUpdate > timeCurrentThread) {
return libQ.reject('Alert: Aborting status update - newer one detected');
} else {
return libQ.resolve(data);
}
};
ControllerMpd.prototype.haltIfNewerUpdateRunning = function (data, timeCurrentThread) {
var self = this;
self.commandRouter.pushConsoleMessage('ControllerMpd::haltIfNewerUpdateRunning');
if (self.timeLatestUpdate > timeCurrentThread) {
return libQ.reject('Alert: Aborting status update - newer one detected');
} else {
return libQ.resolve(data);
}
};
InMemoryCache.prototype.set = function (key, val, maxAgeMs, setWhenNotExist) {
if ((maxAgeMs === undefined || maxAgeMs <= 0) && !this._maxAgeOverride) {
return Q.reject(new Error('maxAgeMs must either be positive or overriden with a positive overrideMaxAgeMs'))
}
this._setInternal(key, val, maxAgeMs, setWhenNotExist)
return Q.resolve(null)
}