08-01-2022, 02:52 AM
Here's the code. Basically same as doing mpc stats which returns results instantly.
daemon/worker.php
inc/mpd.php
daemon/worker.php
Code:
// Check for library update complete
function chkLibraryUpdate() {
//workerLog('chkLibraryUpdate');
$sock = openMpdSock('localhost', 6600);
$status = getMpdStatus($sock);
$stats = getMpdStats($sock);
closeMpdSock($sock);
if (!isset($status['updating_db'])) {
sendEngCmd('libupd_done');
$GLOBALS['check_library_update'] = '0';
workerLog('mpdindex: Done: indexed ' . $stats['artists'] . ' artists, ' . $stats['albums'] . ' albums, ' . $stats['songs'] . ' songs');
workerLog('worker: Job update_library done');
}
}
inc/mpd.php
Code:
function getMpdStats($sock) {
sendMpdCmd($sock, 'stats');
$resp = readMpdResp($sock);
return parseDelimFile($resp, ': ');
}