From d3334612aa568ef7d9688b5186481deeeff5778d Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Tue, 12 May 2020 18:44:10 +0200
Subject: [PATCH] More minor fixes

---
 src/database/queue.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/database/queue.c b/src/database/queue.c
index 0ddba990..ed6ddc6f 100644
--- a/src/database/queue.c
+++ b/src/database/queue.c
@@ -568,11 +568,13 @@ database_queue_shuffle(volatile sqlite3 *db)
     const char *SQL =
         "BEGIN TRANSACTION;"
         /* Create temporary queue */
-        "CREATE TEMPORARY TABLE queue_tmp"
+        "CREATE TEMPORARY TABLE IF NOT EXISTS queue_tmp"
         "  ( position INTEGER PRIMARY KEY AUTOINCREMENT CHECK(position > 0)"
         "  , kara_id INTEGER"
         "  , priority INTEGER NOT NULL DEFAULT 1 CHECK(priority > 0 AND priority < 6)"
         "  );"
+        "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';"
+        "DELETE FROM queue_tmp;"
         /* When current is NULL, that thing is also NULL, so no insertion is done */
         "INSERT INTO queue_tmp (kara_id, priority)"
         "  SELECT kara_id, 5"
@@ -594,8 +596,6 @@ database_queue_shuffle(volatile sqlite3 *db)
         "  SELECT position, kara_id, priority"
         "  FROM queue_tmp"
         "  ORDER BY priority, position;"
-        "DROP TABLE queue_tmp;"
-        "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';"
         /* Set the current to the right kara when needed */
         "UPDATE queue_state"
         "  SET current = CASE"
-- 
GitLab