From 7fee68fa437bfaf692db4a70e1ce767f197cc066 Mon Sep 17 00:00:00 2001 From: djp952 Date: Fri, 30 Aug 2019 17:45:08 -0400 Subject: [PATCH] Fix defect in delete_recording from previous commit --- src/database.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/database.cpp b/src/database.cpp index ac78a045..374a5f6f 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -339,13 +339,14 @@ void delete_recording(sqlite3* instance, char const* recordingid, bool rerecord) { if((instance == nullptr) || (recordingid == nullptr)) return; - // Delete the specified recording from the storage device and the database - execute_non_query(instance, "with httprequest(response) as (select http_post(?1 || '&cmd=delete&rerecord=' || ?2, null)) " - "replace into recording select deviceid, discovered, " + // Delete the specified recording from the storage device + execute_non_query(instance, "select http_post(json_extract(entry.value, '$.CmdURL') || '&cmd=delete&rerecord=' || ?2, null) from recording, json_each(recording.data) as entry " + "where get_recording_id(json_extract(entry.value, '$.CmdURL')) like ?1 limit 1", recordingid, (rerecord) ? 1 : 0); + + // Delete the specified recording from the local database + execute_non_query(instance, "replace into recording select deviceid, discovered, " "(select case when fullkey is null then recording.data else json_remove(recording.data, fullkey) end) as data " - "from httprequest, recording, " - "(select fullkey from recording, json_each(recording.data) as entry where get_recording_id(json_extract(entry.value, '$.CmdURL')) like ?1 limit 1)", - recordingid, (rerecord) ? 1 : 0); + "from recording, (select fullkey from recording, json_each(recording.data) as entry where get_recording_id(json_extract(entry.value, '$.CmdURL')) like ?1 limit 1)", recordingid); } //---------------------------------------------------------------------------