summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2024-05-11 22:03:34 +0800
committerRunxi Yu <me@runxiyu.org>2024-05-11 22:03:34 +0800
commit88506b73ee0d5496d3b7d286edc7e2984f3edc73 (patch)
tree31cb4290a391d37e1ab595e9c5bdcb3500653869
parentd43b80da6e6bd1e0a7c6cbf0b499806b27fc97b7 (diff)
downloadwww-88506b73ee0d5496d3b7d286edc7e2984f3edc73.tar.gz
hybrid.cgi: Don't place file if I don't have enough soace
-rwxr-xr-xhybrid.cgi8
1 files changed, 8 insertions, 0 deletions
diff --git a/hybrid.cgi b/hybrid.cgi
index 8fc7695..cf9cc88 100755
--- a/hybrid.cgi
+++ b/hybrid.cgi
@@ -4,6 +4,7 @@ import sys
 import os
 import cgi
 import pathlib
+import shutil
 
 FBDIR="/srv/fb"
 
@@ -75,6 +76,13 @@ def fbw() -> None:
         sys.stdout.write("\r\n")
         sys.stdout.write("Too large!")
         exit(0)
+    if shutil.disk_usage("/srv/fb").free < 5*(1024**3):
+        sys.stdout.write("Status: 500\r\n")
+        sys.stdout.write("Content-Type: text/plain\r\n")
+        sys.stdout.write("\r\n")
+        sys.stdout.write("I don't have enough space, sorry!")
+        exit(0)
+
     sys.stdout.write("Status: 200\r\n")
     sys.stdout.write("Content-Type: text/plain\r\n")
     sys.stdout.write("\r\n")