aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-12-12 20:39:34 +0100
committerAnton Khirnov <anton@khirnov.net>2023-12-12 20:39:34 +0100
commit4db4b6b8477605442c71f768dbb26ee7c659bef2 (patch)
treed1d55ba899ff84686ed45bd4404e39f7673d7e8a
parent539536069a6e1311921e4ead9b177d33df2bc102 (diff)
Implement DELETE in public mode.
Reprted by another.
-rwxr-xr-xfshare.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/fshare.py b/fshare.py
index ec94b2b..f6e6304 100755
--- a/fshare.py
+++ b/fshare.py
@@ -482,6 +482,15 @@ class FShareRequestHandler(hs.BaseHTTPRequestHandler):
fname = self._process_path(self.path)
+ if self.server.state.urlmap:
+ try:
+ short = self.server.state.urlmap.short_to_full(fname)
+ self._logger.info('%s->%s', fname, short)
+ fname = short
+ except KeyError:
+ self._logger.error('DELETE request for non-existing file: %s', fname)
+ return self.send_error(HTTPStatus.NOT_FOUND)
+
local_path = '/'.join((self.server.data_dir, fname))
try:
os.remove(local_path)