mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-23 18:44:45 +01:00
improve smb support
This commit is contained in:
@@ -57,7 +57,7 @@ namespace Emby.Common.Implementations.Devices
|
||||
{
|
||||
var path = CachePath;
|
||||
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
|
||||
lock (_syncLock)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user