diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2022-12-07 17:40:24 +0100 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2022-12-07 17:40:24 +0100 |
| commit | 2c86bd1875e6e85d5867618e992d850453dae663 (patch) | |
| tree | 671070fb246fd3821bf6f1e58a01c402a2f969d1 /Jellyfin.Api/Controllers/LibraryController.cs | |
| parent | dd5f90802e71083347b6095eb79a9de0b9d34615 (diff) | |
| parent | 3cb7fe50127b1a8158186b390836ee25ae5a50fd (diff) | |
Merge branch 'master' into network-rewrite
Diffstat (limited to 'Jellyfin.Api/Controllers/LibraryController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/LibraryController.cs | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/Jellyfin.Api/Controllers/LibraryController.cs b/Jellyfin.Api/Controllers/LibraryController.cs index 7a57bf1a2..ab2020830 100644 --- a/Jellyfin.Api/Controllers/LibraryController.cs +++ b/Jellyfin.Api/Controllers/LibraryController.cs @@ -104,7 +104,7 @@ namespace Jellyfin.Api.Controllers public ActionResult GetFile([FromRoute, Required] Guid itemId) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } @@ -154,7 +154,7 @@ namespace Jellyfin.Api.Controllers : _libraryManager.GetUserRootFolder()) : _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound("Item not found."); } @@ -171,7 +171,7 @@ namespace Jellyfin.Api.Controllers } var parent = item.GetParent(); - if (parent == null) + if (parent is null) { break; } @@ -220,7 +220,7 @@ namespace Jellyfin.Api.Controllers : _libraryManager.GetUserRootFolder()) : _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound("Item not found."); } @@ -237,7 +237,7 @@ namespace Jellyfin.Api.Controllers } var parent = item.GetParent(); - if (parent == null) + if (parent is null) { break; } @@ -435,7 +435,7 @@ namespace Jellyfin.Api.Controllers { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound("Item not found"); } @@ -449,9 +449,9 @@ namespace Jellyfin.Api.Controllers var dtoOptions = new DtoOptions().AddClientFields(User); BaseItem? parent = item.GetParent(); - while (parent != null) + while (parent is not null) { - if (user != null) + if (user is not null) { parent = TranslateParentItem(parent, user); } @@ -610,14 +610,14 @@ namespace Jellyfin.Api.Controllers public async Task<ActionResult> GetDownload([FromRoute, Required] Guid itemId) { var item = _libraryManager.GetItemById(itemId); - if (item == null) + if (item is null) { return NotFound(); } var user = _userManager.GetUserById(User.GetUserId()); - if (user != null) + if (user is not null) { if (!item.CanDownload(user)) { @@ -632,27 +632,15 @@ namespace Jellyfin.Api.Controllers } } - if (user != null) + if (user is not null) { await LogDownloadAsync(item, user).ConfigureAwait(false); } - var path = item.Path; + // Quotes are valid in linux. They'll possibly cause issues here. + var filename = Path.GetFileName(item.Path)?.Replace("\"", string.Empty, StringComparison.Ordinal); - // Quotes are valid in linux. They'll possibly cause issues here - var filename = (Path.GetFileName(path) ?? string.Empty).Replace("\"", string.Empty, StringComparison.Ordinal); - if (!string.IsNullOrWhiteSpace(filename)) - { - // Kestrel doesn't support non-ASCII characters in headers - if (Regex.IsMatch(filename, @"[^\p{IsBasicLatin}]")) - { - // Manually encoding non-ASCII characters, following https://tools.ietf.org/html/rfc5987#section-3.2.2 - filename = WebUtility.UrlEncode(filename); - } - } - - // TODO determine non-ASCII validity. - return PhysicalFile(path, MimeTypes.GetMimeType(path), filename, true); + return PhysicalFile(item.Path, MimeTypes.GetMimeType(item.Path), filename, true); } /// <summary> @@ -698,8 +686,8 @@ namespace Jellyfin.Api.Controllers .AddClientFields(User); var program = item as IHasProgramAttributes; - bool? isMovie = item is Movie || (program != null && program.IsMovie) || item is Trailer; - bool? isSeries = item is Series || (program != null && program.IsSeries); + bool? isMovie = item is Movie || (program is not null && program.IsMovie) || item is Trailer; + bool? isSeries = item is Series || (program is not null && program.IsSeries); var includeItemTypes = new List<BaseItemKind>(); if (isMovie.Value) |
