mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-27 10:58:44 +01:00
Merge branch 'master' into keyframe_extraction_v1
This commit is contained in:
@@ -8,20 +8,13 @@ namespace MediaBrowser.Model.IO
|
||||
/// </summary>
|
||||
public static class AsyncFile
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether we should use async IO on this platform.
|
||||
/// <see href="https://github.com/dotnet/runtime/issues/16354" />.
|
||||
/// </summary>
|
||||
/// <returns>Returns <c>false</c> on Windows; otherwise <c>true</c>.</returns>
|
||||
public static bool UseAsyncIO => !OperatingSystem.IsWindows();
|
||||
|
||||
/// <summary>
|
||||
/// Opens an existing file for reading.
|
||||
/// </summary>
|
||||
/// <param name="path">The file to be opened for reading.</param>
|
||||
/// <returns>A read-only <see cref="FileStream" /> on the specified path.</returns>
|
||||
public static FileStream OpenRead(string path)
|
||||
=> new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, IODefaults.FileStreamBufferSize, UseAsyncIO);
|
||||
=> new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
||||
|
||||
/// <summary>
|
||||
/// Opens an existing file for writing.
|
||||
@@ -29,6 +22,6 @@ namespace MediaBrowser.Model.IO
|
||||
/// <param name="path">The file to be opened for writing.</param>
|
||||
/// <returns>An unshared <see cref="FileStream" /> object on the specified path with Write access.</returns>
|
||||
public static FileStream OpenWrite(string path)
|
||||
=> new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, UseAsyncIO);
|
||||
=> new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Jellyfin.Extensions;
|
||||
@@ -164,15 +165,16 @@ namespace MediaBrowser.Model.Net
|
||||
return dict;
|
||||
}
|
||||
|
||||
public static string? GetMimeType(string path) => GetMimeType(path, true);
|
||||
public static string GetMimeType(string path) => GetMimeType(path, "application/octet-stream");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the MIME.
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename to find the MIME type of.</param>
|
||||
/// <param name="enableStreamDefault">Whether of not to return a default value if no fitting MIME type is found.</param>
|
||||
/// <returns>The worrect MIME type for the given filename, or `null` if it wasn't found and <paramref name="enableStreamDefault"/> is false.</returns>
|
||||
public static string? GetMimeType(string filename, bool enableStreamDefault)
|
||||
/// <param name="defaultValue">The default value to return if no fitting MIME type is found.</param>
|
||||
/// <returns>The correct MIME type for the given filename, or <paramref name="defaultValue"/> if it wasn't found.</returns>
|
||||
[return: NotNullIfNotNullAttribute("defaultValue")]
|
||||
public static string? GetMimeType(string filename, string? defaultValue = null)
|
||||
{
|
||||
if (filename.Length == 0)
|
||||
{
|
||||
@@ -211,7 +213,7 @@ namespace MediaBrowser.Model.Net
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
return enableStreamDefault ? "application/octet-stream" : null;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static string? ToExtension(string mimeType)
|
||||
|
||||
Reference in New Issue
Block a user