Return disk usage for partition that contains the default project directory. Fixes #1947

This commit is contained in:
grossmj
2021-09-03 12:04:10 +09:30
parent 041d2bd2d6
commit a55c9a5c6a
2 changed files with 17 additions and 2 deletions

View File

@ -48,7 +48,7 @@ def is_safe_path(file_path: str, basedir: str) -> bool:
return Path(basedir).resolve() in test_path.resolve().parents
def check_path_allowed(path):
def check_path_allowed(path: str):
"""
If the server is non local raise an error if
the path is outside project directories
@ -64,3 +64,16 @@ def check_path_allowed(path):
if "local" in config and config.getboolean("local") is False:
raise aiohttp.web.HTTPForbidden(text="The path is not allowed")
def get_mountpoint(path: str):
"""
Find the mount point of a path.
"""
path = os.path.abspath(path)
while path != os.path.sep:
if os.path.ismount(path):
return path
path = os.path.abspath(os.path.join(path, os.pardir))
return path