Purge database before running a rescan
This commit is contained in:
parent
5d0f668941
commit
4ba5e7d31d
@ -15,8 +15,10 @@ for i in {1..$QUEUE_LENGTH}; do
|
|||||||
closest_song=`sqlite3 "$mpdbliss_data_home/db.sqlite3" "SELECT filename FROM (SELECT s2.filename AS filename, distances.distance AS distance FROM distances INNER JOIN songs AS s1 ON s1.id=distances.song1 INNER JOIN songs AS s2 on s2.id=distances.song2 WHERE s1.filename='$current_song' UNION SELECT s1.filename AS filename, distances.distance as distance FROM distances INNER JOIN songs AS s1 ON s1.id=distances.song1 INNER JOIN songs AS s2 on s2.id=distances.song2 WHERE s2.filename=\"$current_song\") ORDER BY distance ASC LIMIT 1"`
|
closest_song=`sqlite3 "$mpdbliss_data_home/db.sqlite3" "SELECT filename FROM (SELECT s2.filename AS filename, distances.distance AS distance FROM distances INNER JOIN songs AS s1 ON s1.id=distances.song1 INNER JOIN songs AS s2 on s2.id=distances.song2 WHERE s1.filename='$current_song' UNION SELECT s1.filename AS filename, distances.distance as distance FROM distances INNER JOIN songs AS s1 ON s1.id=distances.song1 INNER JOIN songs AS s2 on s2.id=distances.song2 WHERE s2.filename=\"$current_song\") ORDER BY distance ASC LIMIT 1"`
|
||||||
if [ ! -z "$closest_song" ]; then
|
if [ ! -z "$closest_song" ]; then
|
||||||
# Push it on the queue
|
# Push it on the queue
|
||||||
mpc add "$closest_song"
|
mpc add "$closest_song" 2>&1 > /dev/null
|
||||||
# Continue using latest pushed song as current song
|
# Continue using latest pushed song as current song
|
||||||
current_song="$closest_song"
|
current_song="$closest_song"
|
||||||
|
# Note: if song could not be found by mpd, it is just not added to the
|
||||||
|
# queue and skipped
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -316,6 +316,12 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
// Check if a full rescan is needed
|
// Check if a full rescan is needed
|
||||||
if (1 == args_info.rescan_flag) {
|
if (1 == args_info.rescan_flag) {
|
||||||
|
dberr = sqlite3_exec(dbh, "BEGIN TRANSACTION; DELETE FROM distances; DELETE FROM songs; COMMIT");
|
||||||
|
if (SQLITE_OK != dberr) {
|
||||||
|
fprintf(stderr, "Error purging existing data in db: %s.\n", sqlite3_errmsg(dbh));
|
||||||
|
sqlite3_close(dbh);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
update_database(conn, last_mtime, mpd_base_path);
|
update_database(conn, last_mtime, mpd_base_path);
|
||||||
}
|
}
|
||||||
// Else, if we requested an update of the db
|
// Else, if we requested an update of the db
|
||||||
|
Loading…
Reference in New Issue
Block a user