diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-05-06 16:20:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-06 16:20:25 -0400 |
| commit | 21edff3ac2175190e0bca98c9a2f967c79ee57c2 (patch) | |
| tree | 6beddce4dffa97eb199da99867f6b493ce197e64 /Emby.Common.Implementations | |
| parent | 3e29d73d0c77c682e161c413703d5e36a8466885 (diff) | |
| parent | 90452d2faf5e0f34698873707e9e505df3c52f9c (diff) | |
Merge pull request #2618 from MediaBrowser/beta
Beta
Diffstat (limited to 'Emby.Common.Implementations')
7 files changed, 71 insertions, 25 deletions
diff --git a/Emby.Common.Implementations/Devices/DeviceId.cs b/Emby.Common.Implementations/Devices/DeviceId.cs index 3d23ab872..1de76456c 100644 --- a/Emby.Common.Implementations/Devices/DeviceId.cs +++ b/Emby.Common.Implementations/Devices/DeviceId.cs @@ -57,7 +57,7 @@ namespace Emby.Common.Implementations.Devices { var path = CachePath; - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); lock (_syncLock) { diff --git a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs index ad6e35700..27fc642f1 100644 --- a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs +++ b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs @@ -131,4 +131,4 @@ namespace Emby.Common.Implementations.EnvironmentInfo Environment.SetEnvironmentVariable(name, value); } } -} +}
\ No newline at end of file diff --git a/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs index 23f33f06c..eb9bc1bd0 100644 --- a/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -418,7 +418,7 @@ namespace Emby.Common.Implementations.HttpClientManager private async Task CacheResponse(HttpResponseInfo response, string responseCachePath) { - _fileSystem.CreateDirectory(Path.GetDirectoryName(responseCachePath)); + _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(responseCachePath)); using (var responseStream = response.Content) { diff --git a/Emby.Common.Implementations/IO/ManagedFileSystem.cs b/Emby.Common.Implementations/IO/ManagedFileSystem.cs index ba73c1ba2..3ed4f650f 100644 --- a/Emby.Common.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Common.Implementations/IO/ManagedFileSystem.cs @@ -546,24 +546,6 @@ namespace Emby.Common.Implementations.IO return Path.DirectorySeparatorChar; } - public bool AreEqual(string path1, string path2) - { - if (path1 == null && path2 == null) - { - return true; - } - - if (path1 == null || path2 == null) - { - return false; - } - - path1 = path1.TrimEnd(GetDirectorySeparatorChar(path1)); - path2 = path2.TrimEnd(GetDirectorySeparatorChar(path2)); - - return string.Equals(path1, path2, StringComparison.OrdinalIgnoreCase); - } - public bool ContainsSubPath(string parentPath, string path) { if (string.IsNullOrEmpty(parentPath)) @@ -588,7 +570,7 @@ namespace Emby.Common.Implementations.IO throw new ArgumentNullException("path"); } - var parent = Path.GetDirectoryName(path); + var parent = GetDirectoryName(path); if (!string.IsNullOrEmpty(parent)) { @@ -598,6 +580,16 @@ namespace Emby.Common.Implementations.IO return true; } + public string GetDirectoryName(string path) + { + if (_sharpCifsFileSystem.IsEnabledForPath(path)) + { + return _sharpCifsFileSystem.GetDirectoryName(path); + } + + return Path.GetDirectoryName(path); + } + public string NormalizePath(string path) { if (string.IsNullOrEmpty(path)) @@ -605,6 +597,11 @@ namespace Emby.Common.Implementations.IO throw new ArgumentNullException("path"); } + if (_sharpCifsFileSystem.IsEnabledForPath(path)) + { + return _sharpCifsFileSystem.NormalizePath(path); + } + if (path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase)) { return path; @@ -613,6 +610,21 @@ namespace Emby.Common.Implementations.IO return path.TrimEnd(GetDirectorySeparatorChar(path)); } + public bool AreEqual(string path1, string path2) + { + if (path1 == null && path2 == null) + { + return true; + } + + if (path1 == null || path2 == null) + { + return false; + } + + return string.Equals(NormalizePath(path1), NormalizePath(path2), StringComparison.OrdinalIgnoreCase); + } + public string GetFileNameWithoutExtension(FileSystemMetadata info) { if (info.IsDirectory) @@ -637,11 +649,17 @@ namespace Emby.Common.Implementations.IO // Cannot use Path.IsPathRooted because it returns false under mono when using windows-based paths, e.g. C:\\ + if (_sharpCifsFileSystem.IsEnabledForPath(path)) + { + return true; + } + if (path.IndexOf("://", StringComparison.OrdinalIgnoreCase) != -1 && !path.StartsWith("file://", StringComparison.OrdinalIgnoreCase)) { return false; } + return true; //return Path.IsPathRooted(path); diff --git a/Emby.Common.Implementations/IO/SharpCifsFileSystem.cs b/Emby.Common.Implementations/IO/SharpCifsFileSystem.cs index c1e429dc9..0a407d64f 100644 --- a/Emby.Common.Implementations/IO/SharpCifsFileSystem.cs +++ b/Emby.Common.Implementations/IO/SharpCifsFileSystem.cs @@ -30,6 +30,34 @@ namespace Emby.Common.Implementations.IO return path.StartsWith("smb://", StringComparison.OrdinalIgnoreCase) || IsUncPath(path); } + public string NormalizePath(string path) + { + if (path.StartsWith("smb://", StringComparison.OrdinalIgnoreCase)) + { + return path; + } + + if (IsUncPath(path)) + { + return ConvertUncToSmb(path); + } + + return path; + } + + public string GetDirectoryName(string path) + { + var separator = GetDirectorySeparatorChar(path); + var result = Path.GetDirectoryName(path); + + if (separator == '/') + { + result = result.Replace('\\', '/'); + } + + return result; + } + public char GetDirectorySeparatorChar(string path) { if (path.IndexOf('/') != -1) diff --git a/Emby.Common.Implementations/Net/NetAcceptSocket.cs b/Emby.Common.Implementations/Net/NetAcceptSocket.cs index 3721709e6..82e7e9b00 100644 --- a/Emby.Common.Implementations/Net/NetAcceptSocket.cs +++ b/Emby.Common.Implementations/Net/NetAcceptSocket.cs @@ -100,7 +100,7 @@ namespace Emby.Common.Implementations.Net #if NET46 public Task SendFile(string path, byte[] preBuffer, byte[] postBuffer, CancellationToken cancellationToken) { - var options = TransmitFileOptions.UseKernelApc; + var options = TransmitFileOptions.UseDefaultWorkerThread; var completionSource = new TaskCompletionSource<bool>(); diff --git a/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index f0518f69e..ac1c55b6b 100644 --- a/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -158,7 +158,7 @@ namespace Emby.Common.Implementations.ScheduledTasks _lastExecutionResult = value; var path = GetHistoryFilePath(); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); lock (_lastExecutionResultSyncLock) { @@ -575,7 +575,7 @@ namespace Emby.Common.Implementations.ScheduledTasks { var path = GetConfigurationFilePath(); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); JsonSerializer.SerializeToFile(triggers, path); } |
