-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,19 +16,69 @@ namespace Shoko.Server.API.v3.Controllers; | |
[Authorize] | ||
public class FolderController : BaseController | ||
{ | ||
private static HashSet<string> ExcludedFormats = new() | ||
{ | ||
"msdos", // fat32 - might be overkill, but the esp (u)efi partition is usually formatted as such. | ||
This comment has been minimized.
Sorry, something went wrong. |
||
"ramfs", | ||
"configfs", | ||
"fusectl", | ||
"tracefs", | ||
"hugetlbfs", | ||
"mqueue", | ||
"debugfs", | ||
"binfmt_misc", | ||
"devpts", | ||
"pstorefs", | ||
"bpf_fs", | ||
"cgroup2fs", | ||
"securityfs", | ||
"proc", | ||
"tmpfs", | ||
"sysfs", | ||
}; | ||
This comment has been minimized.
Sorry, something went wrong.
Cazzar
Member
|
||
|
||
[HttpGet("Drives")] | ||
public ActionResult<IEnumerable<Drive>> GetDrives() | ||
{ | ||
return DriveInfo.GetDrives().Select(d => | ||
{ | ||
if (d.DriveType == DriveType.Unknown) | ||
return null; | ||
|
||
string fullName; | ||
try | ||
{ | ||
fullName = d.RootDirectory.FullName; | ||
} | ||
catch | ||
{ | ||
return null; | ||
} | ||
|
||
string driveFormat; | ||
try | ||
{ | ||
driveFormat = d.DriveFormat; | ||
} | ||
catch | ||
{ | ||
return null; | ||
} | ||
|
||
foreach (var format in ExcludedFormats) | ||
{ | ||
if (driveFormat == format) | ||
return null; | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
Cazzar
Member
|
||
|
||
ChildItems childItems = null; | ||
try | ||
{ | ||
childItems = d.IsReady | ||
? new ChildItems() | ||
{ | ||
Files = d.RootDirectory.GetFiles()?.Length ?? 0, | ||
Folders = d.RootDirectory.GetDirectories()?.Length ?? 0 | ||
Folders = d.RootDirectory.GetDirectories()?.Length ?? 0, | ||
} | ||
: null; | ||
} | ||
|
@@ -38,12 +88,14 @@ public ActionResult<IEnumerable<Drive>> GetDrives() | |
|
||
return new Drive() | ||
{ | ||
Path = d.RootDirectory.FullName, | ||
Path = fullName, | ||
IsAccessible = childItems != null, | ||
Sizes = childItems, | ||
Type = d.DriveType | ||
Type = d.DriveType, | ||
}; | ||
}).ToList(); | ||
}) | ||
.Where(mountPoint => mountPoint != null) | ||
.ToList(); | ||
} | ||
|
||
[HttpGet] | ||
|
This entry may be removed, as it will only ever be relevant to bare-metal installs (which are technically not supported but do work)