diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-03-27 18:55:27 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-03-27 19:01:56 +0100 |
commit | d3ac5b3484fbe4871c52d2f6608e5027152db88d (patch) | |
tree | 499a036e48dcc08b3d13938aae8c2965db2031b7 | |
parent | d596966220975363905cc3dadd693562312017f4 (diff) | |
download | paste-d3ac5b3484fbe4871c52d2f6608e5027152db88d.tar.gz paste-d3ac5b3484fbe4871c52d2f6608e5027152db88d.tar.xz paste-d3ac5b3484fbe4871c52d2f6608e5027152db88d.zip |
DELETE should 404 when nothing was deleted
-rw-r--r-- | paste/__init__.py | 7 | ||||
-rw-r--r-- | paste/store.py | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/paste/__init__.py b/paste/__init__.py index 83cd6b5..f22b5d7 100644 --- a/paste/__init__.py +++ b/paste/__init__.py @@ -263,7 +263,8 @@ def application(environ: Env, start_response: StartResponse) -> Response: ) return [] elif environ["REQUEST_METHOD"] == "DELETE": - store.delete(conn, name) - start_response("204 No Content", []) - return [] + if store.delete(conn, name): + start_response("204 No Content", []) + return [] + return simple_response(start_response, "404 Not Found") return simple_response(start_response, "500 Internal Server Error") diff --git a/paste/store.py b/paste/store.py index 82e66c0..ec51a7f 100644 --- a/paste/store.py +++ b/paste/store.py @@ -54,4 +54,5 @@ def head(conn: Connection, name: str): def delete(conn: Connection, name: str): with conn: - conn.execute("DELETE FROM link WHERE name_hash = DATA_HASH(?)", (name,)) + cur = conn.execute("DELETE FROM link WHERE name_hash = DATA_HASH(?)", (name,)) + return cur.rowcount == 1 |