diff options
author | tv <tv@krebsco.de> | 2021-08-31 20:06:03 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2021-08-31 20:06:03 +0200 |
commit | c04ea486f6e09df4cd29fd90840453b23e2c9bcc (patch) | |
tree | 80e98b44d1aa59ce2e052f15c198ad4a226eb558 /tv/2configs | |
parent | f35e7c588467a6e0f3589857ecf163a88fb5858c (diff) |
tv elm-package-proxy: add DELETE
Diffstat (limited to 'tv/2configs')
-rw-r--r-- | tv/2configs/elm-packages-proxy.nix | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tv/2configs/elm-packages-proxy.nix b/tv/2configs/elm-packages-proxy.nix index 265289b..1df8c7b 100644 --- a/tv/2configs/elm-packages-proxy.nix +++ b/tv/2configs/elm-packages-proxy.nix @@ -197,6 +197,36 @@ in { exit ;; + 'DELETE /packages/'*) + + author=$req_x_author + pname=$req_x_package + user=$req_x_user + version=$req_x_version + + zipball=${cfg.packageDir}/$author/$pname/$version/zipball + elmjson=$HOME/cache/$author%2F$pname%2F$version%2Felm.json + endpointjson=$HOME/cache/$author%2F$pname%2F$version%2Fendpoint.json + + if test -e "$zipball"; then + zipball_owner=$(attr -q -g X-User "$zipball" || :) + if test "$zipball_owner" = "$req_x_user"; then + echo "user $user is deleting package $author/$pname@$version" >&2 + rm -f "$elmjson" + rm -f "$endpointjson" + rm "$zipball" + string_response 200 OK \ + "package deleted: $author/$pname@$version" \ + text/plain + exit + else + string_response 403 Forbidden \ + "package already exists: $author/$pname@$version" \ + text/plain + exit + fi + fi + ;; 'GET /all-packages'|'POST /all-packages') response=$(mktemp -t htgen.$$.elm-packages-proxy.all-packages.XXXXXXXX) |