feat: admin maintenance page (#1096)

* fix build typo

* generate types

* setup maintenance api for common cleanup actions

* admin maintenance page

* remove duplicate use-with-caution
This commit is contained in:
Hayden
2022-03-24 22:17:38 -08:00
committed by GitHub
parent ffb3b45ac2
commit 4ef649231b
12 changed files with 376 additions and 2 deletions

28
mealie/pkgs/img/static.py Normal file
View File

@@ -0,0 +1,28 @@
NOT_WEBP = {
".jpg",
".jpeg",
".jpe",
".jif",
".jfif",
".jfi",
".png",
".gif",
".tiff",
".tif",
".psd",
".raw",
".arw",
".cr2",
".nrw",
".k25",
".bmp",
".dib",
".heif",
".heic",
".ind",
".jp2",
".svg",
".svgz",
".ai",
".eps",
}

View File

@@ -1,3 +1,7 @@
import os
from pathlib import Path
def pretty_size(size: int) -> str:
"""
Pretty size takes in a integer value of a file size and returns the most applicable
@@ -13,3 +17,17 @@ def pretty_size(size: int) -> str:
return f"{round(size / 1024 / 1024 / 1024, 2)} GB"
else:
return f"{round(size / 1024 / 1024 / 1024 / 1024, 2)} TB"
def get_dir_size(path: Path | str) -> int:
"""
Get the size of a directory
"""
total_size = os.path.getsize(path)
for item in os.listdir(path):
itempath = os.path.join(path, item)
if os.path.isfile(itempath):
total_size += os.path.getsize(itempath)
elif os.path.isdir(itempath):
total_size += get_dir_size(itempath)
return total_size