rework file system libs

pull/1154/head
Luke Pulverenti 8 years ago
parent 79b28e2465
commit 38badd4d28

@ -6,7 +6,7 @@ using System.Security;
using System.Text; using System.Text;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
namespace MediaBrowser.ServerApplication.Native namespace Emby.Common.Implementations.IO
{ {
public class LnkShortcutHandler :IShortcutHandler public class LnkShortcutHandler :IShortcutHandler
{ {
@ -35,7 +35,6 @@ namespace MediaBrowser.ServerApplication.Native
/// <summary> /// <summary>
/// Class NativeMethods /// Class NativeMethods
/// </summary> /// </summary>
[SuppressUnmanagedCodeSecurity]
public static class NativeMethods public static class NativeMethods
{ {
/// <summary> /// <summary>

@ -5,6 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System;
namespace Emby.Common.Implementations.IO namespace Emby.Common.Implementations.IO
{ {
@ -18,17 +19,17 @@ namespace Emby.Common.Implementations.IO
private readonly bool _supportsAsyncFileStreams; private readonly bool _supportsAsyncFileStreams;
private char[] _invalidFileNameChars; private char[] _invalidFileNameChars;
private readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>(); private readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>();
private bool EnableFileSystemRequestConcat = true; private bool EnableFileSystemRequestConcat;
private string _tempPath; private string _tempPath;
public ManagedFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars, bool enableFileSystemRequestConcat, string tempPath) public ManagedFileSystem(ILogger logger, IEnvironmentInfo environmentInfo, string tempPath)
{ {
Logger = logger; Logger = logger;
_supportsAsyncFileStreams = supportsAsyncFileStreams; _supportsAsyncFileStreams = true;
_tempPath = tempPath; _tempPath = tempPath;
EnableFileSystemRequestConcat = enableFileSystemRequestConcat; EnableFileSystemRequestConcat = false;
SetInvalidFileNameChars(enableManagedInvalidFileNameChars); SetInvalidFileNameChars(environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows);
} }
public void AddShortcutHandler(IShortcutHandler handler) public void AddShortcutHandler(IShortcutHandler handler)

@ -61,7 +61,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Emby.Common.Implementations; using Emby.Common.Implementations;
using Emby.Common.Implementations.Archiving; using Emby.Common.Implementations.Archiving;
using Emby.Common.Implementations.Networking; using Emby.Common.Implementations.IO;
using Emby.Common.Implementations.Reflection; using Emby.Common.Implementations.Reflection;
using Emby.Common.Implementations.Serialization; using Emby.Common.Implementations.Serialization;
using Emby.Common.Implementations.TextEncoding; using Emby.Common.Implementations.TextEncoding;
@ -93,7 +93,7 @@ using Emby.Server.Implementations.Social;
using Emby.Server.Implementations.Channels; using Emby.Server.Implementations.Channels;
using Emby.Server.Implementations.Collections; using Emby.Server.Implementations.Collections;
using Emby.Server.Implementations.Dto; using Emby.Server.Implementations.Dto;
using Emby.Server.Implementations.EntryPoints; using Emby.Server.Implementations.IO;
using Emby.Server.Implementations.FileOrganization; using Emby.Server.Implementations.FileOrganization;
using Emby.Server.Implementations.HttpServer; using Emby.Server.Implementations.HttpServer;
using Emby.Server.Implementations.HttpServer.Security; using Emby.Server.Implementations.HttpServer.Security;
@ -294,6 +294,13 @@ namespace Emby.Server.Core
ImageEncoder = imageEncoder; ImageEncoder = imageEncoder;
SetBaseExceptionMessage(); SetBaseExceptionMessage();
if (environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows)
{
fileSystem.AddShortcutHandler(new LnkShortcutHandler());
}
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
} }
private Version _version; private Version _version;

@ -10,6 +10,8 @@ namespace MediaBrowser.Model.IO
/// </summary> /// </summary>
public interface IFileSystem public interface IFileSystem
{ {
void AddShortcutHandler(IShortcutHandler handler);
/// <summary> /// <summary>
/// Determines whether the specified filename is shortcut. /// Determines whether the specified filename is shortcut.
/// </summary> /// </summary>

@ -105,12 +105,11 @@ namespace MediaBrowser.Server.Mac
// Allow all https requests // Allow all https requests
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; }); ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
var fileSystem = new MonoFileSystem(logManager.GetLogger("FileSystem"), false, false, appPaths.TempDirectory); var environmentInfo = GetEnvironmentInfo();
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
_fileSystem = fileSystem; var fileSystem = new MonoFileSystem(logManager.GetLogger("FileSystem"), environmentInfo, appPaths.TempDirectory);
var environmentInfo = GetEnvironmentInfo(); _fileSystem = fileSystem;
var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger,
logManager, logManager,

@ -1,13 +1,14 @@
using Emby.Common.Implementations.IO; using Emby.Common.Implementations.IO;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System;
using Mono.Unix.Native; using Mono.Unix.Native;
namespace MediaBrowser.Server.Mono.Native namespace MediaBrowser.Server.Mono.Native
{ {
public class MonoFileSystem : ManagedFileSystem public class MonoFileSystem : ManagedFileSystem
{ {
public MonoFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars, string tempPath) public MonoFileSystem(ILogger logger, IEnvironmentInfo environment, string tempPath)
: base(logger, supportsAsyncFileStreams, enableManagedInvalidFileNameChars, true, tempPath) : base(logger, environment, tempPath)
{ {
} }

@ -114,12 +114,11 @@ namespace MediaBrowser.Server.Mono
// Allow all https requests // Allow all https requests
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; }); ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
var fileSystem = new MonoFileSystem(logManager.GetLogger("FileSystem"), false, false, appPaths.TempDirectory); var environmentInfo = GetEnvironmentInfo();
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
FileSystem = fileSystem; var fileSystem = new MonoFileSystem(logManager.GetLogger("FileSystem"), environmentInfo, appPaths.TempDirectory);
var environmentInfo = GetEnvironmentInfo(); FileSystem = fileSystem;
var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths); var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths);

@ -331,9 +331,9 @@ namespace MediaBrowser.ServerApplication
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options) private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options)
{ {
var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, false, appPaths.TempDirectory); var environmentInfo = new EnvironmentInfo();
fileSystem.AddShortcutHandler(new LnkShortcutHandler());
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem)); var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), environmentInfo, appPaths.TempDirectory);
var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths); var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths);
@ -345,7 +345,7 @@ namespace MediaBrowser.ServerApplication
fileSystem, fileSystem,
new PowerManagement(), new PowerManagement(),
"emby.windows.zip", "emby.windows.zip",
new EnvironmentInfo(), environmentInfo,
imageEncoder, imageEncoder,
new Server.Startup.Common.SystemEvents(logManager.GetLogger("SystemEvents")), new Server.Startup.Common.SystemEvents(logManager.GetLogger("SystemEvents")),
new RecyclableMemoryStreamProvider(), new RecyclableMemoryStreamProvider(),

@ -142,7 +142,6 @@
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="MainStartup.cs" /> <Compile Include="MainStartup.cs" />
<Compile Include="Native\LnkShortcutHandler.cs" />
<Compile Include="Native\PowerManagement.cs" /> <Compile Include="Native\PowerManagement.cs" />
<Compile Include="Native\Standby.cs" /> <Compile Include="Native\Standby.cs" />
<Compile Include="Native\ServerAuthorization.cs" /> <Compile Include="Native\ServerAuthorization.cs" />

@ -4,6 +4,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices.ComTypes; using System.Runtime.InteropServices.ComTypes;
using Emby.Common.Implementations.IO;
using Emby.Server.CinemaMode; using Emby.Server.CinemaMode;
using Emby.Server.Connect; using Emby.Server.Connect;
using Emby.Server.Core; using Emby.Server.Core;

Loading…
Cancel
Save