mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-01-18 23:11:21 -05:00
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:
28
mealie/pkgs/img/static.py
Normal file
28
mealie/pkgs/img/static.py
Normal 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",
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user