use all flag to check drives

This commit is contained in:
mungai-njoroge
2023-11-14 12:54:28 +03:00
parent 5f1bb28f5d
commit 1d71ba856b
5 changed files with 26 additions and 8 deletions
+13 -5
View File
@@ -68,14 +68,24 @@ def get_all_drives(is_win: bool = False):
"""
Returns a list of all the drives on a Windows machine.
"""
drives = psutil.disk_partitions()
drives = psutil.disk_partitions(all=True)
drives = [d.mountpoint for d in drives]
if is_win:
drives = [win_replace_slash(d) for d in drives]
else:
remove = ["/boot", "/boot/efi", "/tmp"]
drives = [d for d in drives if d not in remove]
remove = (
"/boot",
"/tmp",
"/snap",
"/var",
"/sys",
"/proc",
"/etc",
"/run",
"/dev",
)
drives = [d for d in drives if not d.startswith(remove)]
return drives
@@ -94,8 +104,6 @@ def list_folders():
req_dir = "$root"
if req_dir == "$root":
# req_dir = settings.USER_HOME_DIR
# if is_win:
return {
"folders": [{"name": d, "path": d} for d in get_all_drives(is_win=is_win)]
}