From fed64387bd09f3ad14ffd9145233d55be42b9034 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Wed, 10 Nov 2021 09:49:28 +0000 Subject: [PATCH] Invert count/write logic Previously, write was the actual default action, and in some forms of the command, the action value isn't actually checked against the possible values, so on a typo, it would write instead of count. --- wpull2-requeue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wpull2-requeue b/wpull2-requeue index 5fe82b5..5cd7bc0 100755 --- a/wpull2-requeue +++ b/wpull2-requeue @@ -30,12 +30,12 @@ urlpattern="$1" query='FROM queued_urls JOIN url_strings ON url_string_id = url_strings.id WHERE url LIKE "'"${urlpattern}"'" ESCAPE "\" AND status = "skipped" AND try_count > 3' -if [[ "${action}" == 'count' ]] +if [[ "${action}" == 'write' ]] then - sqlite3 "${filename}" "SELECT COUNT(queued_urls.id) ${query}" + sqlite3 "${filename}" 'UPDATE queued_urls SET status = "todo", try_count = 0, status_code = NULL WHERE id IN (SELECT queued_urls.id '"${query}"')' elif [[ "${action}" == 'print' ]] then sqlite3 "${filename}" "SELECT queued_urls.*, url_strings.* ${query}" else - sqlite3 "${filename}" 'UPDATE queued_urls SET status = "todo", try_count = 0, status_code = NULL WHERE id IN (SELECT queued_urls.id '"${query}"')' + sqlite3 "${filename}" "SELECT COUNT(queued_urls.id) ${query}" fi