mirror of https://github.com/jellyfin/jellyfin.git
Remove FileSystem.GetStream
This commit is contained in:
parent
6eac7f0fa7
commit
c8409d2ea1
|
@ -42,7 +42,7 @@ namespace DvdLib.Ifo
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (var vmgFs = _fileSystem.GetFileStream(vmgPath.FullName, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read))
|
using (var vmgFs = new FileStream(vmgPath.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
{
|
{
|
||||||
using (var vmgRead = new BigEndianBinaryReader(vmgFs))
|
using (var vmgRead = new BigEndianBinaryReader(vmgFs))
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ namespace DvdLib.Ifo
|
||||||
{
|
{
|
||||||
VTSPaths[vtsNum] = vtsPath;
|
VTSPaths[vtsNum] = vtsPath;
|
||||||
|
|
||||||
using (var vtsFs = _fileSystem.GetFileStream(vtsPath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read))
|
using (var vtsFs = new FileStream(vtsPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
{
|
{
|
||||||
using (var vtsRead = new BigEndianBinaryReader(vtsFs))
|
using (var vtsRead = new BigEndianBinaryReader(vtsFs))
|
||||||
{
|
{
|
||||||
|
|
|
@ -385,7 +385,7 @@ namespace Emby.Dlna
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(systemProfilesPath);
|
Directory.CreateDirectory(systemProfilesPath);
|
||||||
|
|
||||||
using (var fileStream = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(fileStream);
|
await stream.CopyToAsync(fileStream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Drawing;
|
using MediaBrowser.Model.Drawing;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Extensions;
|
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
@ -129,7 +128,7 @@ namespace Emby.Drawing
|
||||||
{
|
{
|
||||||
var file = await ProcessImage(options).ConfigureAwait(false);
|
var file = await ProcessImage(options).ConfigureAwait(false);
|
||||||
|
|
||||||
using (var fileStream = _fileSystem.GetFileStream(file.Item1, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read, true))
|
using (var fileStream = new FileStream(file.Item1, FileMode.Open, FileAccess.Read, FileShare.Read, IODefaults.FileStreamBufferSize, true))
|
||||||
{
|
{
|
||||||
await fileStream.CopyToAsync(toStream).ConfigureAwait(false);
|
await fileStream.CopyToAsync(toStream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -599,7 +599,7 @@ namespace Emby.Server.Implementations
|
||||||
HttpsPort = ServerConfiguration.DefaultHttpsPort;
|
HttpsPort = ServerConfiguration.DefaultHttpsPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonSerializer = new JsonSerializer(FileSystemManager);
|
JsonSerializer = new JsonSerializer();
|
||||||
|
|
||||||
if (Plugins != null)
|
if (Plugins != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -243,7 +243,7 @@ namespace Emby.Server.Implementations.Devices
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var fs = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(fs).ConfigureAwait(false);
|
await stream.CopyToAsync(fs).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ namespace Emby.Server.Implementations.HttpClientManager
|
||||||
if (File.Exists(responseCachePath)
|
if (File.Exists(responseCachePath)
|
||||||
&& _fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow)
|
&& _fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow)
|
||||||
{
|
{
|
||||||
var stream = _fileSystem.GetFileStream(responseCachePath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read, true);
|
var stream = new FileStream(responseCachePath, FileMode.Open, FileAccess.Read, FileShare.Read, IODefaults.FileStreamBufferSize, true);
|
||||||
|
|
||||||
return new HttpResponseInfo
|
return new HttpResponseInfo
|
||||||
{
|
{
|
||||||
|
@ -220,7 +220,7 @@ namespace Emby.Server.Implementations.HttpClientManager
|
||||||
FileMode.Create,
|
FileMode.Create,
|
||||||
FileAccess.Write,
|
FileAccess.Write,
|
||||||
FileShare.None,
|
FileShare.None,
|
||||||
StreamDefaults.DefaultFileStreamBufferSize,
|
IODefaults.FileStreamBufferSize,
|
||||||
true))
|
true))
|
||||||
{
|
{
|
||||||
await response.Content.CopyToAsync(fileStream).ConfigureAwait(false);
|
await response.Content.CopyToAsync(fileStream).ConfigureAwait(false);
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
SetRangeValues();
|
SetRangeValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileShare = FileShareMode.Read;
|
FileShare = FileShare.Read;
|
||||||
Cookies = new List<Cookie>();
|
Cookies = new List<Cookie>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
|
|
||||||
public List<Cookie> Cookies { get; private set; }
|
public List<Cookie> Cookies { get; private set; }
|
||||||
|
|
||||||
public FileShareMode FileShare { get; set; }
|
public FileShare FileShare { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the options.
|
/// Gets the options.
|
||||||
|
@ -222,17 +222,17 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task TransmitFile(Stream stream, string path, long offset, long count, FileShareMode fileShareMode, CancellationToken cancellationToken)
|
public async Task TransmitFile(Stream stream, string path, long offset, long count, FileShare fileShare, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var fileOpenOptions = FileOpenOptions.SequentialScan;
|
var fileOptions = FileOptions.SequentialScan;
|
||||||
|
|
||||||
// use non-async filestream along with read due to https://github.com/dotnet/corefx/issues/6039
|
// use non-async filestream along with read due to https://github.com/dotnet/corefx/issues/6039
|
||||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
fileOpenOptions |= FileOpenOptions.Asynchronous;
|
fileOptions |= FileOptions.Asynchronous;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var fs = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, fileShareMode, fileOpenOptions))
|
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, fileShare, IODefaults.FileStreamBufferSize, fileOptions))
|
||||||
{
|
{
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
|
@ -245,7 +245,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await fs.CopyToAsync(stream, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);
|
await fs.CopyToAsync(stream, IODefaults.CopyToBufferSize, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,87 +365,6 @@ namespace Emby.Server.Implementations.IO
|
||||||
return GetLastWriteTimeUtc(GetFileSystemInfo(path));
|
return GetLastWriteTimeUtc(GetFileSystemInfo(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the file stream.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">The path.</param>
|
|
||||||
/// <param name="mode">The mode.</param>
|
|
||||||
/// <param name="access">The access.</param>
|
|
||||||
/// <param name="share">The share.</param>
|
|
||||||
/// <param name="isAsync">if set to <c>true</c> [is asynchronous].</param>
|
|
||||||
/// <returns>FileStream.</returns>
|
|
||||||
public virtual Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, bool isAsync = false)
|
|
||||||
{
|
|
||||||
if (isAsync)
|
|
||||||
{
|
|
||||||
return GetFileStream(path, mode, access, share, FileOpenOptions.Asynchronous);
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetFileStream(path, mode, access, share, FileOpenOptions.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, FileOpenOptions fileOpenOptions)
|
|
||||||
=> new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), 4096, GetFileOptions(fileOpenOptions));
|
|
||||||
|
|
||||||
private static FileOptions GetFileOptions(FileOpenOptions mode)
|
|
||||||
{
|
|
||||||
var val = (int)mode;
|
|
||||||
return (FileOptions)val;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static FileMode GetFileMode(FileOpenMode mode)
|
|
||||||
{
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
//case FileOpenMode.Append:
|
|
||||||
// return FileMode.Append;
|
|
||||||
case FileOpenMode.Create:
|
|
||||||
return FileMode.Create;
|
|
||||||
case FileOpenMode.CreateNew:
|
|
||||||
return FileMode.CreateNew;
|
|
||||||
case FileOpenMode.Open:
|
|
||||||
return FileMode.Open;
|
|
||||||
case FileOpenMode.OpenOrCreate:
|
|
||||||
return FileMode.OpenOrCreate;
|
|
||||||
//case FileOpenMode.Truncate:
|
|
||||||
// return FileMode.Truncate;
|
|
||||||
default:
|
|
||||||
throw new Exception("Unrecognized FileOpenMode");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static FileAccess GetFileAccess(FileAccessMode mode)
|
|
||||||
{
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
//case FileAccessMode.ReadWrite:
|
|
||||||
// return FileAccess.ReadWrite;
|
|
||||||
case FileAccessMode.Write:
|
|
||||||
return FileAccess.Write;
|
|
||||||
case FileAccessMode.Read:
|
|
||||||
return FileAccess.Read;
|
|
||||||
default:
|
|
||||||
throw new Exception("Unrecognized FileAccessMode");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static FileShare GetFileShare(FileShareMode mode)
|
|
||||||
{
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case FileShareMode.ReadWrite:
|
|
||||||
return FileShare.ReadWrite;
|
|
||||||
case FileShareMode.Write:
|
|
||||||
return FileShare.Write;
|
|
||||||
case FileShareMode.Read:
|
|
||||||
return FileShare.Read;
|
|
||||||
case FileShareMode.None:
|
|
||||||
return FileShare.None;
|
|
||||||
default:
|
|
||||||
throw new Exception("Unrecognized FileShareMode");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void SetHidden(string path, bool isHidden)
|
public virtual void SetHidden(string path, bool isHidden)
|
||||||
{
|
{
|
||||||
if (OperatingSystem.Id != OperatingSystemId.Windows)
|
if (OperatingSystem.Id != OperatingSystemId.Windows)
|
||||||
|
|
|
@ -15,14 +15,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IHttpClient _httpClient;
|
private readonly IHttpClient _httpClient;
|
||||||
private readonly IFileSystem _fileSystem;
|
|
||||||
private readonly IStreamHelper _streamHelper;
|
private readonly IStreamHelper _streamHelper;
|
||||||
|
|
||||||
public DirectRecorder(ILogger logger, IHttpClient httpClient, IFileSystem fileSystem, IStreamHelper streamHelper)
|
public DirectRecorder(ILogger logger, IHttpClient httpClient, IStreamHelper streamHelper)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
_fileSystem = fileSystem;
|
|
||||||
_streamHelper = streamHelper;
|
_streamHelper = streamHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +43,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
|
Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
|
||||||
|
|
||||||
using (var output = _fileSystem.GetFileStream(targetFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
using (var output = new FileStream(targetFile, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
onStarted();
|
onStarted();
|
||||||
|
|
||||||
|
@ -81,7 +79,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
|
Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
|
||||||
|
|
||||||
using (var output = _fileSystem.GetFileStream(targetFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
using (var output = new FileStream(targetFile, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
onStarted();
|
onStarted();
|
||||||
|
|
||||||
|
|
|
@ -1664,10 +1664,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
{
|
{
|
||||||
if (mediaSource.RequiresLooping || !(mediaSource.Container ?? string.Empty).EndsWith("ts", StringComparison.OrdinalIgnoreCase) || (mediaSource.Protocol != MediaProtocol.File && mediaSource.Protocol != MediaProtocol.Http))
|
if (mediaSource.RequiresLooping || !(mediaSource.Container ?? string.Empty).EndsWith("ts", StringComparison.OrdinalIgnoreCase) || (mediaSource.Protocol != MediaProtocol.File && mediaSource.Protocol != MediaProtocol.Http))
|
||||||
{
|
{
|
||||||
return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, _processFactory, _config);
|
return new EncodedRecorder(_logger, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, _processFactory, _config);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DirectRecorder(_logger, _httpClient, _fileSystem, _streamHelper);
|
return new DirectRecorder(_logger, _httpClient, _streamHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSuccessfulRecording(TimerInfo timer, string path)
|
private void OnSuccessfulRecording(TimerInfo timer, string path)
|
||||||
|
@ -1888,7 +1888,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var stream = _fileSystem.GetFileStream(nfoPath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
using (var stream = new FileStream(nfoPath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
var settings = new XmlWriterSettings
|
var settings = new XmlWriterSettings
|
||||||
{
|
{
|
||||||
|
@ -1952,7 +1952,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var stream = _fileSystem.GetFileStream(nfoPath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
using (var stream = new FileStream(nfoPath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
var settings = new XmlWriterSettings
|
var settings = new XmlWriterSettings
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,6 @@ using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Diagnostics;
|
using MediaBrowser.Model.Diagnostics;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
@ -24,7 +23,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
public class EncodedRecorder : IRecorder
|
public class EncodedRecorder : IRecorder
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IFileSystem _fileSystem;
|
|
||||||
private readonly IMediaEncoder _mediaEncoder;
|
private readonly IMediaEncoder _mediaEncoder;
|
||||||
private readonly IServerApplicationPaths _appPaths;
|
private readonly IServerApplicationPaths _appPaths;
|
||||||
private bool _hasExited;
|
private bool _hasExited;
|
||||||
|
@ -38,7 +36,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
|
|
||||||
public EncodedRecorder(
|
public EncodedRecorder(
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
IFileSystem fileSystem,
|
|
||||||
IMediaEncoder mediaEncoder,
|
IMediaEncoder mediaEncoder,
|
||||||
IServerApplicationPaths appPaths,
|
IServerApplicationPaths appPaths,
|
||||||
IJsonSerializer json,
|
IJsonSerializer json,
|
||||||
|
@ -46,7 +43,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
IServerConfigurationManager config)
|
IServerConfigurationManager config)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_fileSystem = fileSystem;
|
|
||||||
_mediaEncoder = mediaEncoder;
|
_mediaEncoder = mediaEncoder;
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
_json = json;
|
_json = json;
|
||||||
|
@ -107,7 +103,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(logFilePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(logFilePath));
|
||||||
|
|
||||||
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
|
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
|
||||||
_logFileStream = _fileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true);
|
_logFileStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);
|
||||||
|
|
||||||
var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(_json.SerializeToString(mediaSource) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);
|
var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(_json.SerializeToString(mediaSource) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);
|
||||||
_logFileStream.Write(commandLineLogMessageBytes, 0, commandLineLogMessageBytes.Length);
|
_logFileStream.Write(commandLineLogMessageBytes, 0, commandLineLogMessageBytes.Length);
|
||||||
|
|
|
@ -96,7 +96,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
FileMode.Open,
|
FileMode.Open,
|
||||||
FileAccess.Read,
|
FileAccess.Read,
|
||||||
FileShare.ReadWrite,
|
FileShare.ReadWrite,
|
||||||
StreamDefaults.DefaultFileStreamBufferSize,
|
IODefaults.FileStreamBufferSize,
|
||||||
allowAsyncFileRead ? FileOptions.SequentialScan | FileOptions.Asynchronous : FileOptions.SequentialScan);
|
allowAsyncFileRead ? FileOptions.SequentialScan | FileOptions.Asynchronous : FileOptions.SequentialScan);
|
||||||
|
|
||||||
public Task DeleteTempFiles()
|
public Task DeleteTempFiles()
|
||||||
|
@ -199,7 +199,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
await StreamHelper.CopyToAsync(
|
await StreamHelper.CopyToAsync(
|
||||||
inputStream,
|
inputStream,
|
||||||
stream,
|
stream,
|
||||||
StreamDefaults.DefaultCopyToBufferSize,
|
IODefaults.CopyToBufferSize,
|
||||||
emptyReadLimit,
|
emptyReadLimit,
|
||||||
cancellationToken).ConfigureAwait(false);
|
cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,12 +127,12 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
Logger.LogInformation("Beginning {0} stream to {1}", GetType().Name, TempFilePath);
|
Logger.LogInformation("Beginning {0} stream to {1}", GetType().Name, TempFilePath);
|
||||||
using (response)
|
using (response)
|
||||||
using (var stream = response.Content)
|
using (var stream = response.Content)
|
||||||
using (var fileStream = FileSystem.GetFileStream(TempFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.None))
|
using (var fileStream = new FileStream(TempFilePath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
await StreamHelper.CopyToAsync(
|
await StreamHelper.CopyToAsync(
|
||||||
stream,
|
stream,
|
||||||
fileStream,
|
fileStream,
|
||||||
StreamDefaults.DefaultCopyToBufferSize,
|
IODefaults.CopyToBufferSize,
|
||||||
() => Resolve(openTaskCompletionSource),
|
() => Resolve(openTaskCompletionSource),
|
||||||
cancellationToken).ConfigureAwait(false);
|
cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Model.IO;
|
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Serialization
|
namespace Emby.Server.Implementations.Serialization
|
||||||
|
@ -12,13 +11,15 @@ namespace Emby.Server.Implementations.Serialization
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class JsonSerializer : IJsonSerializer
|
public class JsonSerializer : IJsonSerializer
|
||||||
{
|
{
|
||||||
private readonly IFileSystem _fileSystem;
|
public JsonSerializer()
|
||||||
|
|
||||||
public JsonSerializer(
|
|
||||||
IFileSystem fileSystem)
|
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.DateHandler.ISO8601;
|
||||||
Configure();
|
ServiceStack.Text.JsConfig.ExcludeTypeInfo = true;
|
||||||
|
ServiceStack.Text.JsConfig.IncludeNullValues = false;
|
||||||
|
ServiceStack.Text.JsConfig.AlwaysUseUtc = true;
|
||||||
|
ServiceStack.Text.JsConfig.AssumeUtc = true;
|
||||||
|
|
||||||
|
ServiceStack.Text.JsConfig<Guid>.SerializeFn = SerializeGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -81,7 +82,7 @@ namespace Emby.Server.Implementations.Serialization
|
||||||
throw new ArgumentNullException(nameof(file));
|
throw new ArgumentNullException(nameof(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var stream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
using (var stream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
SerializeToStream(obj, stream);
|
SerializeToStream(obj, stream);
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,6 @@ namespace Emby.Server.Implementations.Serialization
|
||||||
throw new ArgumentNullException(nameof(stream));
|
throw new ArgumentNullException(nameof(stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ServiceStack.Text.JsonSerializer.DeserializeFromStreamAsync<T>(stream);
|
return ServiceStack.Text.JsonSerializer.DeserializeFromStreamAsync<T>(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,20 +225,6 @@ namespace Emby.Server.Implementations.Serialization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Configures this instance.
|
|
||||||
/// </summary>
|
|
||||||
private void Configure()
|
|
||||||
{
|
|
||||||
ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.DateHandler.ISO8601;
|
|
||||||
ServiceStack.Text.JsConfig.ExcludeTypeInfo = true;
|
|
||||||
ServiceStack.Text.JsConfig.IncludeNullValues = false;
|
|
||||||
ServiceStack.Text.JsConfig.AlwaysUseUtc = true;
|
|
||||||
ServiceStack.Text.JsConfig.AssumeUtc = true;
|
|
||||||
|
|
||||||
ServiceStack.Text.JsConfig<Guid>.SerializeFn = SerializeGuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string SerializeGuid(Guid guid)
|
private static string SerializeGuid(Guid guid)
|
||||||
{
|
{
|
||||||
if (guid.Equals(Guid.Empty))
|
if (guid.Equals(Guid.Empty))
|
||||||
|
|
|
@ -656,7 +656,7 @@ namespace MediaBrowser.Api.Images
|
||||||
IsHeadRequest = isHeadRequest,
|
IsHeadRequest = isHeadRequest,
|
||||||
Path = imageResult.Item1,
|
Path = imageResult.Item1,
|
||||||
|
|
||||||
FileShare = FileShareMode.Read
|
FileShare = FileShare.Read
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,12 +274,10 @@ namespace MediaBrowser.Api.Images
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));
|
||||||
using (var stream = result.Content)
|
using (var stream = result.Content)
|
||||||
{
|
using (var filestream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true))
|
||||||
using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
|
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(filestream).ConfigureAwait(false);
|
await stream.CopyToAsync(filestream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
|
||||||
File.WriteAllText(pointerCachePath, fullCachePath);
|
File.WriteAllText(pointerCachePath, fullCachePath);
|
||||||
|
|
|
@ -305,7 +305,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));
|
||||||
using (var stream = result.Content)
|
using (var stream = result.Content)
|
||||||
using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
|
using (var filestream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true))
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(filestream).ConfigureAwait(false);
|
await stream.CopyToAsync(filestream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,7 +261,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
var logFilePath = Path.Combine(ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, logFilePrefix + "-" + Guid.NewGuid() + ".txt");
|
var logFilePath = Path.Combine(ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, logFilePrefix + "-" + Guid.NewGuid() + ".txt");
|
||||||
|
|
||||||
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
|
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
|
||||||
Stream logStream = FileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true);
|
Stream logStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);
|
||||||
|
|
||||||
var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(Request.AbsoluteUri + Environment.NewLine + Environment.NewLine + JsonSerializer.SerializeToString(state.MediaSource) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);
|
var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(Request.AbsoluteUri + Environment.NewLine + Environment.NewLine + JsonSerializer.SerializeToString(state.MediaSource) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);
|
||||||
await logStream.WriteAsync(commandLineLogMessageBytes, 0, commandLineLogMessageBytes.Length, cancellationTokenSource.Token).ConfigureAwait(false);
|
await logStream.WriteAsync(commandLineLogMessageBytes, 0, commandLineLogMessageBytes.Length, cancellationTokenSource.Token).ConfigureAwait(false);
|
||||||
|
|
|
@ -168,7 +168,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
|
|
||||||
private string GetLivePlaylistText(string path, int segmentLength)
|
private string GetLivePlaylistText(string path, int segmentLength)
|
||||||
{
|
{
|
||||||
using (var stream = FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite))
|
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
{
|
{
|
||||||
using (var reader = new StreamReader(stream))
|
using (var reader = new StreamReader(stream))
|
||||||
{
|
{
|
||||||
|
@ -211,7 +211,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Need to use FileShareMode.ReadWrite because we're reading the file at the same time it's being written
|
// Need to use FileShare.ReadWrite because we're reading the file at the same time it's being written
|
||||||
using (var fileStream = GetPlaylistFileStream(playlist))
|
using (var fileStream = GetPlaylistFileStream(playlist))
|
||||||
{
|
{
|
||||||
using (var reader = new StreamReader(fileStream))
|
using (var reader = new StreamReader(fileStream))
|
||||||
|
@ -252,11 +252,11 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return FileSystem.GetFileStream(tmpPath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, FileOpenOptions.SequentialScan);
|
return new FileStream(tmpPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, FileOptions.SequentialScan);
|
||||||
}
|
}
|
||||||
catch (IOException)
|
catch (IOException)
|
||||||
{
|
{
|
||||||
return FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, FileOpenOptions.SequentialScan);
|
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, FileOptions.SequentialScan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -537,7 +537,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||||
{
|
{
|
||||||
Path = segmentPath,
|
Path = segmentPath,
|
||||||
FileShare = FileShareMode.ReadWrite,
|
FileShare = FileShare.ReadWrite,
|
||||||
OnComplete = () =>
|
OnComplete = () =>
|
||||||
{
|
{
|
||||||
Logger.LogDebug("finished serving {0}", segmentPath);
|
Logger.LogDebug("finished serving {0}", segmentPath);
|
||||||
|
|
|
@ -140,7 +140,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
||||||
file = Path.Combine(ServerConfigurationManager.GetTranscodePath(), file);
|
file = Path.Combine(ServerConfigurationManager.GetTranscodePath(), file);
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file, FileShareMode.ReadWrite);
|
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<object> GetFileResult(string path, string playlistPath)
|
private Task<object> GetFileResult(string path, string playlistPath)
|
||||||
|
@ -150,7 +150,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||||
{
|
{
|
||||||
Path = path,
|
Path = path,
|
||||||
FileShare = FileShareMode.ReadWrite,
|
FileShare = FileShare.ReadWrite,
|
||||||
OnComplete = () =>
|
OnComplete = () =>
|
||||||
{
|
{
|
||||||
if (transcodingJob != null)
|
if (transcodingJob != null)
|
||||||
|
|
|
@ -248,7 +248,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
// ContentType = contentType,
|
// ContentType = contentType,
|
||||||
// IsHeadRequest = isHeadRequest,
|
// IsHeadRequest = isHeadRequest,
|
||||||
// Path = outputPath,
|
// Path = outputPath,
|
||||||
// FileShare = FileShareMode.ReadWrite,
|
// FileShare = FileShare.ReadWrite,
|
||||||
// OnComplete = () =>
|
// OnComplete = () =>
|
||||||
// {
|
// {
|
||||||
// if (transcodingJob != null)
|
// if (transcodingJob != null)
|
||||||
|
|
|
@ -21,8 +21,6 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
private readonly CancellationToken _cancellationToken;
|
private readonly CancellationToken _cancellationToken;
|
||||||
private readonly Dictionary<string, string> _outputHeaders;
|
private readonly Dictionary<string, string> _outputHeaders;
|
||||||
|
|
||||||
const int StreamCopyToBufferSize = 81920;
|
|
||||||
|
|
||||||
private long _bytesWritten = 0;
|
private long _bytesWritten = 0;
|
||||||
public long StartPosition { get; set; }
|
public long StartPosition { get; set; }
|
||||||
public bool AllowEndOfFile = true;
|
public bool AllowEndOfFile = true;
|
||||||
|
@ -52,14 +50,14 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
|
|
||||||
private Stream GetInputStream(bool allowAsyncFileRead)
|
private Stream GetInputStream(bool allowAsyncFileRead)
|
||||||
{
|
{
|
||||||
var fileOpenOptions = FileOpenOptions.SequentialScan;
|
var fileOptions = FileOptions.SequentialScan;
|
||||||
|
|
||||||
if (allowAsyncFileRead)
|
if (allowAsyncFileRead)
|
||||||
{
|
{
|
||||||
fileOpenOptions |= FileOpenOptions.Asynchronous;
|
fileOptions |= FileOptions.Asynchronous;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _fileSystem.GetFileStream(_path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, fileOpenOptions);
|
return new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, fileOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WriteToAsync(Stream outputStream, CancellationToken cancellationToken)
|
public async Task WriteToAsync(Stream outputStream, CancellationToken cancellationToken)
|
||||||
|
@ -127,7 +125,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
|
|
||||||
private async Task<int> CopyToInternalAsyncWithSyncRead(Stream source, Stream destination, CancellationToken cancellationToken)
|
private async Task<int> CopyToInternalAsyncWithSyncRead(Stream source, Stream destination, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var array = new byte[StreamCopyToBufferSize];
|
var array = new byte[IODefaults.CopyToBufferSize];
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
int totalBytesRead = 0;
|
int totalBytesRead = 0;
|
||||||
|
|
||||||
|
@ -154,7 +152,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
|
|
||||||
private async Task<int> CopyToInternalAsync(Stream source, Stream destination, CancellationToken cancellationToken)
|
private async Task<int> CopyToInternalAsync(Stream source, Stream destination, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var array = new byte[StreamCopyToBufferSize];
|
var array = new byte[IODefaults.CopyToBufferSize];
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
int totalBytesRead = 0;
|
int totalBytesRead = 0;
|
||||||
|
|
||||||
|
|
|
@ -170,10 +170,10 @@ namespace MediaBrowser.Api.System
|
||||||
// For older files, assume fully static
|
// For older files, assume fully static
|
||||||
if (file.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-1))
|
if (file.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-1))
|
||||||
{
|
{
|
||||||
return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShareMode.Read);
|
return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShare.Read);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShareMode.ReadWrite);
|
return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShare.ReadWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -653,7 +653,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
// _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fallbackFontPath));
|
// _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fallbackFontPath));
|
||||||
// using (var stream = _assemblyInfo.GetManifestResourceStream(GetType(), GetType().Namespace + ".DroidSansFallback.ttf"))
|
// using (var stream = _assemblyInfo.GetManifestResourceStream(GetType(), GetType().Namespace + ".DroidSansFallback.ttf"))
|
||||||
// {
|
// {
|
||||||
// using (var fileStream = _fileSystem.GetFileStream(fallbackFontPath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
// using (var fileStream = new FileStream(fallbackFontPath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
// {
|
// {
|
||||||
// stream.CopyTo(fileStream);
|
// stream.CopyTo(fileStream);
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace MediaBrowser.Controller.Net
|
||||||
/// <param name="path">The path.</param>
|
/// <param name="path">The path.</param>
|
||||||
/// <param name="fileShare">The file share.</param>
|
/// <param name="fileShare">The file share.</param>
|
||||||
/// <returns>System.Object.</returns>
|
/// <returns>System.Object.</returns>
|
||||||
Task<object> GetStaticFileResult(IRequest requestContext, string path, FileShareMode fileShare = FileShareMode.Read);
|
Task<object> GetStaticFileResult(IRequest requestContext, string path, FileShare fileShare = FileShare.Read);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the static file result.
|
/// Gets the static file result.
|
||||||
|
|
|
@ -24,12 +24,12 @@ namespace MediaBrowser.Controller.Net
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public long? ContentLength { get; set; }
|
public long? ContentLength { get; set; }
|
||||||
|
|
||||||
public FileShareMode FileShare { get; set; }
|
public FileShare FileShare { get; set; }
|
||||||
|
|
||||||
public StaticResultOptions()
|
public StaticResultOptions()
|
||||||
{
|
{
|
||||||
ResponseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
ResponseHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
FileShare = FileShareMode.Read;
|
FileShare = FileShare.Read;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace MediaBrowser.LocalMetadata.Savers
|
||||||
// On Windows, savint the file will fail if the file is hidden or readonly
|
// On Windows, savint the file will fail if the file is hidden or readonly
|
||||||
FileSystem.SetAttributes(path, false, false);
|
FileSystem.SetAttributes(path, false, false);
|
||||||
|
|
||||||
using (var filestream = FileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
using (var filestream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
stream.CopyTo(filestream);
|
stream.CopyTo(filestream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,27 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using BDInfo.IO;
|
using BDInfo.IO;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
|
|
||||||
namespace MediaBrowser.MediaEncoding.BdInfo
|
namespace MediaBrowser.MediaEncoding.BdInfo
|
||||||
{
|
{
|
||||||
class BdInfoDirectoryInfo : BDInfo.IO.IDirectoryInfo
|
class BdInfoDirectoryInfo : IDirectoryInfo
|
||||||
{
|
{
|
||||||
IFileSystem _fileSystem = null;
|
private readonly IFileSystem _fileSystem = null;
|
||||||
|
|
||||||
FileSystemMetadata _impl = null;
|
private readonly FileSystemMetadata _impl = null;
|
||||||
|
|
||||||
|
public BdInfoDirectoryInfo(IFileSystem fileSystem, string path)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_impl = _fileSystem.GetDirectoryInfo(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BdInfoDirectoryInfo(IFileSystem fileSystem, FileSystemMetadata impl)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_impl = impl;
|
||||||
|
}
|
||||||
|
|
||||||
public string Name => _impl.Name;
|
public string Name => _impl.Name;
|
||||||
|
|
||||||
|
@ -25,22 +36,11 @@ namespace MediaBrowser.MediaEncoding.BdInfo
|
||||||
{
|
{
|
||||||
return new BdInfoDirectoryInfo(_fileSystem, parentFolder);
|
return new BdInfoDirectoryInfo(_fileSystem, parentFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BdInfoDirectoryInfo(IFileSystem fileSystem, string path)
|
|
||||||
{
|
|
||||||
_fileSystem = fileSystem;
|
|
||||||
_impl = _fileSystem.GetDirectoryInfo(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
private BdInfoDirectoryInfo(IFileSystem fileSystem, FileSystemMetadata impl)
|
|
||||||
{
|
|
||||||
_fileSystem = fileSystem;
|
|
||||||
_impl = impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IDirectoryInfo[] GetDirectories()
|
public IDirectoryInfo[] GetDirectories()
|
||||||
{
|
{
|
||||||
return Array.ConvertAll(_fileSystem.GetDirectories(_impl.FullName).ToArray(),
|
return Array.ConvertAll(_fileSystem.GetDirectories(_impl.FullName).ToArray(),
|
||||||
|
@ -50,20 +50,20 @@ namespace MediaBrowser.MediaEncoding.BdInfo
|
||||||
public IFileInfo[] GetFiles()
|
public IFileInfo[] GetFiles()
|
||||||
{
|
{
|
||||||
return Array.ConvertAll(_fileSystem.GetFiles(_impl.FullName).ToArray(),
|
return Array.ConvertAll(_fileSystem.GetFiles(_impl.FullName).ToArray(),
|
||||||
x => new BdInfoFileInfo(_fileSystem, x));
|
x => new BdInfoFileInfo(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFileInfo[] GetFiles(string searchPattern)
|
public IFileInfo[] GetFiles(string searchPattern)
|
||||||
{
|
{
|
||||||
return Array.ConvertAll(_fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false, false).ToArray(),
|
return Array.ConvertAll(_fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false, false).ToArray(),
|
||||||
x => new BdInfoFileInfo(_fileSystem, x));
|
x => new BdInfoFileInfo(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFileInfo[] GetFiles(string searchPattern, System.IO.SearchOption searchOption)
|
public IFileInfo[] GetFiles(string searchPattern, System.IO.SearchOption searchOption)
|
||||||
{
|
{
|
||||||
return Array.ConvertAll(_fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false,
|
return Array.ConvertAll(_fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false,
|
||||||
searchOption.HasFlag(System.IO.SearchOption.AllDirectories)).ToArray(),
|
searchOption.HasFlag(System.IO.SearchOption.AllDirectories)).ToArray(),
|
||||||
x => new BdInfoFileInfo(_fileSystem, x));
|
x => new BdInfoFileInfo(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDirectoryInfo FromFileSystemPath(Model.IO.IFileSystem fs, string path)
|
public static IDirectoryInfo FromFileSystemPath(Model.IO.IFileSystem fs, string path)
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
|
using System.IO;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
|
|
||||||
namespace MediaBrowser.MediaEncoding.BdInfo
|
namespace MediaBrowser.MediaEncoding.BdInfo
|
||||||
{
|
{
|
||||||
class BdInfoFileInfo : BDInfo.IO.IFileInfo
|
class BdInfoFileInfo : BDInfo.IO.IFileInfo
|
||||||
{
|
{
|
||||||
IFileSystem _fileSystem = null;
|
|
||||||
|
|
||||||
FileSystemMetadata _impl = null;
|
FileSystemMetadata _impl = null;
|
||||||
|
|
||||||
public string Name => _impl.Name;
|
public string Name => _impl.Name;
|
||||||
|
@ -18,18 +17,17 @@ namespace MediaBrowser.MediaEncoding.BdInfo
|
||||||
|
|
||||||
public bool IsDir => _impl.IsDirectory;
|
public bool IsDir => _impl.IsDirectory;
|
||||||
|
|
||||||
public BdInfoFileInfo(IFileSystem fileSystem, FileSystemMetadata impl)
|
public BdInfoFileInfo(FileSystemMetadata impl)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public System.IO.Stream OpenRead()
|
public System.IO.Stream OpenRead()
|
||||||
{
|
{
|
||||||
return _fileSystem.GetFileStream(FullName,
|
return new FileStream(FullName,
|
||||||
FileOpenMode.Open,
|
FileMode.Open,
|
||||||
FileAccessMode.Read,
|
FileAccess.Read,
|
||||||
FileShareMode.Read);
|
FileShare.Read);
|
||||||
}
|
}
|
||||||
|
|
||||||
public System.IO.StreamReader OpenText()
|
public System.IO.StreamReader OpenText()
|
||||||
|
|
|
@ -691,7 +691,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
|
|
||||||
if (!string.Equals(text, newText))
|
if (!string.Equals(text, newText))
|
||||||
{
|
{
|
||||||
using (var fileStream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
using (var fileStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
using (var writer = new StreamWriter(fileStream, encoding))
|
using (var writer = new StreamWriter(fileStream, encoding))
|
||||||
{
|
{
|
||||||
writer.Write(newText);
|
writer.Write(newText);
|
||||||
|
|
|
@ -98,20 +98,6 @@ namespace MediaBrowser.Model.IO
|
||||||
/// <returns>DateTime.</returns>
|
/// <returns>DateTime.</returns>
|
||||||
DateTime GetLastWriteTimeUtc(string path);
|
DateTime GetLastWriteTimeUtc(string path);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the file stream.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">The path.</param>
|
|
||||||
/// <param name="mode">The mode.</param>
|
|
||||||
/// <param name="access">The access.</param>
|
|
||||||
/// <param name="share">The share.</param>
|
|
||||||
/// <param name="isAsync">if set to <c>true</c> [is asynchronous].</param>
|
|
||||||
/// <returns>FileStream.</returns>
|
|
||||||
Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, bool isAsync = false);
|
|
||||||
|
|
||||||
Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share,
|
|
||||||
FileOpenOptions fileOpenOptions);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Swaps the files.
|
/// Swaps the files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -218,128 +204,4 @@ namespace MediaBrowser.Model.IO
|
||||||
List<FileSystemMetadata> GetDrives();
|
List<FileSystemMetadata> GetDrives();
|
||||||
void SetExecutable(string path);
|
void SetExecutable(string path);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Investigate if can be replaced by the one from System.IO ?
|
|
||||||
public enum FileOpenMode
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Specifies that the operating system should create a new file. This requires System.Security.Permissions.FileIOPermissionAccess.Write
|
|
||||||
// permission. If the file already exists, an System.IO.IOException exception is
|
|
||||||
// thrown.
|
|
||||||
CreateNew = 1,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Specifies that the operating system should create a new file. If the file already
|
|
||||||
// exists, it will be overwritten. This requires System.Security.Permissions.FileIOPermissionAccess.Write
|
|
||||||
// permission. FileMode.Create is equivalent to requesting that if the file does
|
|
||||||
// not exist, use System.IO.FileMode.CreateNew; otherwise, use System.IO.FileMode.Truncate.
|
|
||||||
// If the file already exists but is a hidden file, an System.UnauthorizedAccessException
|
|
||||||
// exception is thrown.
|
|
||||||
Create = 2,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Specifies that the operating system should open an existing file. The ability
|
|
||||||
// to open the file is dependent on the value specified by the System.IO.FileAccess
|
|
||||||
// enumeration. A System.IO.FileNotFoundException exception is thrown if the file
|
|
||||||
// does not exist.
|
|
||||||
Open = 3,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Specifies that the operating system should open a file if it exists; otherwise,
|
|
||||||
// a new file should be created. If the file is opened with FileAccess.Read, System.Security.Permissions.FileIOPermissionAccess.Read
|
|
||||||
// permission is required. If the file access is FileAccess.Write, System.Security.Permissions.FileIOPermissionAccess.Write
|
|
||||||
// permission is required. If the file is opened with FileAccess.ReadWrite, both
|
|
||||||
// System.Security.Permissions.FileIOPermissionAccess.Read and System.Security.Permissions.FileIOPermissionAccess.Write
|
|
||||||
// permissions are required.
|
|
||||||
OpenOrCreate = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum FileAccessMode
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Read access to the file. Data can be read from the file. Combine with Write for
|
|
||||||
// read/write access.
|
|
||||||
Read = 1,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Write access to the file. Data can be written to the file. Combine with Read
|
|
||||||
// for read/write access.
|
|
||||||
Write = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum FileShareMode
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Declines sharing of the current file. Any request to open the file (by this process
|
|
||||||
// or another process) will fail until the file is closed.
|
|
||||||
None = 0,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Allows subsequent opening of the file for reading. If this flag is not specified,
|
|
||||||
// any request to open the file for reading (by this process or another process)
|
|
||||||
// will fail until the file is closed. However, even if this flag is specified,
|
|
||||||
// additional permissions might still be needed to access the file.
|
|
||||||
Read = 1,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Allows subsequent opening of the file for writing. If this flag is not specified,
|
|
||||||
// any request to open the file for writing (by this process or another process)
|
|
||||||
// will fail until the file is closed. However, even if this flag is specified,
|
|
||||||
// additional permissions might still be needed to access the file.
|
|
||||||
Write = 2,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Allows subsequent opening of the file for reading or writing. If this flag is
|
|
||||||
// not specified, any request to open the file for reading or writing (by this process
|
|
||||||
// or another process) will fail until the file is closed. However, even if this
|
|
||||||
// flag is specified, additional permissions might still be needed to access the
|
|
||||||
// file.
|
|
||||||
ReadWrite = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Represents advanced options for creating a System.IO.FileStream object.
|
|
||||||
[Flags]
|
|
||||||
public enum FileOpenOptions
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Indicates that the system should write through any intermediate cache and go
|
|
||||||
// directly to disk.
|
|
||||||
WriteThrough = int.MinValue,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Indicates that no additional options should be used when creating a System.IO.FileStream
|
|
||||||
// object.
|
|
||||||
None = 0,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Indicates that a file is encrypted and can be decrypted only by using the same
|
|
||||||
// user account used for encryption.
|
|
||||||
Encrypted = 16384,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Indicates that a file is automatically deleted when it is no longer in use.
|
|
||||||
DeleteOnClose = 67108864,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Indicates that the file is to be accessed sequentially from beginning to end.
|
|
||||||
// The system can use this as a hint to optimize file caching. If an application
|
|
||||||
// moves the file pointer for random access, optimum caching may not occur; however,
|
|
||||||
// correct operation is still guaranteed.
|
|
||||||
SequentialScan = 134217728,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Indicates that the file is accessed randomly. The system can use this as a hint
|
|
||||||
// to optimize file caching.
|
|
||||||
RandomAccess = 268435456,
|
|
||||||
//
|
|
||||||
// Summary:
|
|
||||||
// Indicates that a file can be used for asynchronous reading and writing.
|
|
||||||
Asynchronous = 1073741824
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
namespace MediaBrowser.Model.IO
|
namespace MediaBrowser.Model.IO
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class StreamDefaults.
|
/// Class IODefaults.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class StreamDefaults
|
public static class IODefaults
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default copy to buffer size.
|
/// The default copy to buffer size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int DefaultCopyToBufferSize = 81920;
|
public const int CopyToBufferSize = 81920;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default file stream buffer size.
|
/// The default file stream buffer size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int DefaultFileStreamBufferSize = 4096;
|
public const int FileStreamBufferSize = 4096;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -244,9 +244,9 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
_fileSystem.SetAttributes(path, false, false);
|
_fileSystem.SetAttributes(path, false, false);
|
||||||
|
|
||||||
using (var fs = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.Asynchronous))
|
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous))
|
||||||
{
|
{
|
||||||
await source.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);
|
await source.CopyToAsync(fs, IODefaults.CopyToBufferSize, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_config.Configuration.SaveMetadataHidden)
|
if (_config.Configuration.SaveMetadataHidden)
|
||||||
|
|
|
@ -25,14 +25,12 @@ namespace MediaBrowser.Providers.Manager
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IProviderManager _providerManager;
|
private readonly IProviderManager _providerManager;
|
||||||
private readonly IServerConfigurationManager _config;
|
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
|
||||||
public ItemImageProvider(ILogger logger, IProviderManager providerManager, IServerConfigurationManager config, IFileSystem fileSystem)
|
public ItemImageProvider(ILogger logger, IProviderManager providerManager, IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_providerManager = providerManager;
|
_providerManager = providerManager;
|
||||||
_config = config;
|
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +139,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
{
|
{
|
||||||
var mimeType = MimeTypes.GetMimeType(response.Path);
|
var mimeType = MimeTypes.GetMimeType(response.Path);
|
||||||
|
|
||||||
var stream = _fileSystem.GetFileStream(response.Path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read, true);
|
var stream = new FileStream(response.Path, FileMode.Open, FileAccess.Read, FileShare.Read, IODefaults.FileStreamBufferSize, true);
|
||||||
|
|
||||||
await _providerManager.SaveImage(item, stream, mimeType, imageType, null, cancellationToken).ConfigureAwait(false);
|
await _providerManager.SaveImage(item, stream, mimeType, imageType, null, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemImageProvider = new ItemImageProvider(Logger, ProviderManager, ServerConfigurationManager, FileSystem);
|
var itemImageProvider = new ItemImageProvider(Logger, ProviderManager, FileSystem);
|
||||||
var localImagesFailed = false;
|
var localImagesFailed = false;
|
||||||
|
|
||||||
var allImageProviders = ((ProviderManager)ProviderManager).GetImageProviders(item, refreshOptions).ToList();
|
var allImageProviders = ((ProviderManager)ProviderManager).GetImageProviders(item, refreshOptions).ToList();
|
||||||
|
|
|
@ -182,7 +182,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
throw new ArgumentNullException(nameof(source));
|
throw new ArgumentNullException(nameof(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileStream = _fileSystem.GetFileStream(source, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true);
|
var fileStream = new FileStream(source, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, true);
|
||||||
|
|
||||||
return new ImageSaver(ConfigurationManager, _libraryMonitor, _fileSystem, _logger).SaveImage(item, fileStream, mimeType, type, imageIndex, saveLocallyWithMedia, cancellationToken);
|
return new ImageSaver(ConfigurationManager, _libraryMonitor, _fileSystem, _logger).SaveImage(item, fileStream, mimeType, type, imageIndex, saveLocallyWithMedia, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
|
@ -164,11 +165,10 @@ namespace MediaBrowser.Providers.Music
|
||||||
{
|
{
|
||||||
Url = url,
|
Url = url,
|
||||||
CancellationToken = cancellationToken
|
CancellationToken = cancellationToken
|
||||||
|
|
||||||
},
|
},
|
||||||
"GET").ConfigureAwait(false))
|
HttpMethod.Get).ConfigureAwait(false))
|
||||||
using (var response = httpResponse.Content)
|
using (var response = httpResponse.Content)
|
||||||
using (var xmlFileStream = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
|
using (var xmlFileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true))
|
||||||
{
|
{
|
||||||
await response.CopyToAsync(xmlFileStream).ConfigureAwait(false);
|
await response.CopyToAsync(xmlFileStream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
|
@ -152,12 +153,12 @@ namespace MediaBrowser.Providers.Music
|
||||||
CancellationToken = cancellationToken,
|
CancellationToken = cancellationToken,
|
||||||
BufferContent = true
|
BufferContent = true
|
||||||
},
|
},
|
||||||
"GET").ConfigureAwait(false))
|
HttpMethod.Get).ConfigureAwait(false))
|
||||||
using (var response = httpResponse.Content)
|
using (var response = httpResponse.Content)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
|
|
||||||
using (var xmlFileStream = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
|
using (var xmlFileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true))
|
||||||
{
|
{
|
||||||
await response.CopyToAsync(xmlFileStream).ConfigureAwait(false);
|
await response.CopyToAsync(xmlFileStream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ namespace MediaBrowser.Providers.Omdb
|
||||||
|
|
||||||
string resultString;
|
string resultString;
|
||||||
|
|
||||||
using (var stream = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read))
|
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
{
|
{
|
||||||
using (var reader = new StreamReader(stream, new UTF8Encoding(false)))
|
using (var reader = new StreamReader(stream, new UTF8Encoding(false)))
|
||||||
{
|
{
|
||||||
|
@ -228,7 +228,7 @@ namespace MediaBrowser.Providers.Omdb
|
||||||
|
|
||||||
string resultString;
|
string resultString;
|
||||||
|
|
||||||
using (var stream = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read))
|
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
{
|
{
|
||||||
using (var reader = new StreamReader(stream, new UTF8Encoding(false)))
|
using (var reader = new StreamReader(stream, new UTF8Encoding(false)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace MediaBrowser.Providers.Studios
|
||||||
|
|
||||||
private RemoteImageInfo GetImage(BaseItem item, string filename, ImageType type, string remoteFilename)
|
private RemoteImageInfo GetImage(BaseItem item, string filename, ImageType type, string remoteFilename)
|
||||||
{
|
{
|
||||||
var list = GetAvailableImages(filename, _fileSystem);
|
var list = GetAvailableImages(filename);
|
||||||
|
|
||||||
var match = FindMatch(item, list);
|
var match = FindMatch(item, list);
|
||||||
|
|
||||||
|
@ -179,9 +179,9 @@ namespace MediaBrowser.Providers.Studios
|
||||||
.Replace("/", string.Empty);
|
.Replace("/", string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> GetAvailableImages(string file, IFileSystem fileSystem)
|
public IEnumerable<string> GetAvailableImages(string file)
|
||||||
{
|
{
|
||||||
using (var fileStream = fileSystem.GetFileStream(file, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read))
|
using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
{
|
{
|
||||||
using (var reader = new StreamReader(fileStream))
|
using (var reader = new StreamReader(fileStream))
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@ using MediaBrowser.Model.Globalization;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using static MediaBrowser.Model.IO.StreamDefaults;
|
using static MediaBrowser.Model.IO.IODefaults;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Subtitles
|
namespace MediaBrowser.Providers.Subtitles
|
||||||
{
|
{
|
||||||
|
@ -210,7 +210,7 @@ namespace MediaBrowser.Providers.Subtitles
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(savePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(savePath));
|
||||||
|
|
||||||
using (var fs = new FileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.Read, DefaultFileStreamBufferSize, true))
|
using (var fs = new FileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.Read, FileStreamBufferSize, true))
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(fs).ConfigureAwait(false);
|
await stream.CopyToAsync(fs).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@ namespace MediaBrowser.Providers.Tmdb.People
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath));
|
||||||
|
|
||||||
using (var fs = _fileSystem.GetFileStream(dataFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
|
using (var fs = new FileStream(dataFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true))
|
||||||
{
|
{
|
||||||
await json.CopyToAsync(fs).ConfigureAwait(false);
|
await json.CopyToAsync(fs).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,7 +425,7 @@ namespace MediaBrowser.WebDashboard.Api
|
||||||
private async Task DumpFile(PackageCreator packageCreator, string resourceVirtualPath, string destinationFilePath, string mode, string appVersion)
|
private async Task DumpFile(PackageCreator packageCreator, string resourceVirtualPath, string destinationFilePath, string mode, string appVersion)
|
||||||
{
|
{
|
||||||
using (var stream = await packageCreator.GetResource(resourceVirtualPath, mode, null, appVersion).ConfigureAwait(false))
|
using (var stream = await packageCreator.GetResource(resourceVirtualPath, mode, null, appVersion).ConfigureAwait(false))
|
||||||
using (var fs = _fileSystem.GetFileStream(destinationFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
using (var fs = new FileStream(destinationFilePath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(fs);
|
await stream.CopyToAsync(fs);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue