浏览代码

Fix UnauthorizedAccessException in GetDrives

```
[15:01:24] [ERR] [55] Jellyfin.Server.Middleware.ExceptionMiddleware: Error processing request. URL GET /Environment/Drives.
System.UnauthorizedAccessException: Access to the path is denied.
 ---> System.IO.IOException: Operation not permitted
   --- End of inner exception stack trace ---
   at System.IO.DriveInfo.CheckStatfsResultAndThrowIfNecessary(Int32 result)
   at System.IO.DriveInfo.get_TotalSize()
   at Emby.Server.Implementations.IO.ManagedFileSystem.<>c.<GetDrives>b__32_0(DriveInfo d) in /home/bond/dev/jellyfin/Emby.Server.Implementations/IO/ManagedFileSystem.cs:line 583
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.ToList()
   at Emby.Server.Implementations.IO.ManagedFileSystem.GetDrives() in /home/bond/dev/jellyfin/Emby.Server.Implementations/IO/ManagedFileSystem.cs:line 583
   at Jellyfin.Api.Controllers.EnvironmentController.GetDrives() in /home/bond/dev/jellyfin/Jellyfin.Api/Controllers/EnvironmentController.cs:line 153
   at lambda_method559(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
```
Bond_009 3 年之前
父节点
当前提交
0f52896691
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      Emby.Server.Implementations/IO/ManagedFileSystem.cs

+ 5 - 1
Emby.Server.Implementations/IO/ManagedFileSystem.cs

@@ -580,7 +580,11 @@ namespace Emby.Server.Implementations.IO
         {
         {
             // check for ready state to avoid waiting for drives to timeout
             // check for ready state to avoid waiting for drives to timeout
             // some drives on linux have no actual size or are used for other purposes
             // some drives on linux have no actual size or are used for other purposes
-            return DriveInfo.GetDrives().Where(d => d.IsReady && d.TotalSize != 0 && d.DriveType != DriveType.Ram)
+            return DriveInfo.GetDrives()
+                .Where(
+                    d => (d.DriveType == DriveType.Fixed || d.DriveType == DriveType.Network || d.DriveType == DriveType.Removable)
+                        && d.IsReady
+                        && d.TotalSize != 0)
                 .Select(d => new FileSystemMetadata
                 .Select(d => new FileSystemMetadata
                 {
                 {
                     Name = d.Name,
                     Name = d.Name,