mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 01:24:44 +01:00
improve smb support
This commit is contained in:
@@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
return;
|
||||
}
|
||||
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
|
||||
_jsonSerializer.SerializeToFile(mediaSources, path);
|
||||
}
|
||||
@@ -1105,7 +1105,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
{
|
||||
try
|
||||
{
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
|
||||
_jsonSerializer.SerializeToFile(result, path);
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ namespace Emby.Server.Implementations.FileOrganization
|
||||
_libraryMonitor.ReportFileSystemChangeBeginning(path);
|
||||
|
||||
var renameRelatedFiles = !hasRenamedFiles &&
|
||||
string.Equals(Path.GetDirectoryName(path), Path.GetDirectoryName(result.TargetPath), StringComparison.OrdinalIgnoreCase);
|
||||
string.Equals(_fileSystem.GetDirectoryName(path), _fileSystem.GetDirectoryName(result.TargetPath), StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (renameRelatedFiles)
|
||||
{
|
||||
@@ -432,7 +432,7 @@ namespace Emby.Server.Implementations.FileOrganization
|
||||
|
||||
// Now find other files
|
||||
var originalFilenameWithoutExtension = Path.GetFileNameWithoutExtension(path);
|
||||
var directory = Path.GetDirectoryName(path);
|
||||
var directory = _fileSystem.GetDirectoryName(path);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(originalFilenameWithoutExtension) && !string.IsNullOrWhiteSpace(directory))
|
||||
{
|
||||
@@ -445,7 +445,7 @@ namespace Emby.Server.Implementations.FileOrganization
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
directory = Path.GetDirectoryName(file);
|
||||
directory = _fileSystem.GetDirectoryName(file);
|
||||
var filename = Path.GetFileName(file);
|
||||
|
||||
filename = filename.Replace(originalFilenameWithoutExtension, targetFilenameWithoutExtension,
|
||||
@@ -499,7 +499,7 @@ namespace Emby.Server.Implementations.FileOrganization
|
||||
.Select(i => i.Path)
|
||||
.ToList();
|
||||
|
||||
var folder = Path.GetDirectoryName(targetPath);
|
||||
var folder = _fileSystem.GetDirectoryName(targetPath);
|
||||
var targetFileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(targetPath);
|
||||
|
||||
try
|
||||
@@ -529,7 +529,7 @@ namespace Emby.Server.Implementations.FileOrganization
|
||||
|
||||
_libraryMonitor.ReportFileSystemChangeBeginning(result.TargetPath);
|
||||
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(result.TargetPath));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(result.TargetPath));
|
||||
|
||||
var targetAlreadyExists = _fileSystem.FileExists(result.TargetPath);
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.IO
|
||||
{
|
||||
item = LibraryManager.FindByPath(path, null);
|
||||
|
||||
path = System.IO.Path.GetDirectoryName(path);
|
||||
path = _fileSystem.GetDirectoryName(path);
|
||||
}
|
||||
|
||||
if (item != null)
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Emby.Server.Implementations.Images
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var outputPathWithoutExtension = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid().ToString("N"));
|
||||
FileSystem.CreateDirectory(Path.GetDirectoryName(outputPathWithoutExtension));
|
||||
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPathWithoutExtension));
|
||||
string outputPath = await CreateImage(item, itemsWithImages, outputPathWithoutExtension, imageType, 0).ConfigureAwait(false);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(outputPath))
|
||||
@@ -205,7 +205,7 @@ namespace Emby.Server.Implementations.Images
|
||||
|
||||
private async Task<string> CreateCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
|
||||
{
|
||||
FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
|
||||
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPath));
|
||||
|
||||
var options = new ImageCollageOptions
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
var parentFolderName = Path.GetFileName(Path.GetDirectoryName(path));
|
||||
var parentFolderName = Path.GetFileName(_fileSystem.GetDirectoryName(path));
|
||||
|
||||
if (string.Equals(parentFolderName, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
||||
@@ -1962,8 +1962,34 @@ namespace Emby.Server.Implementations.Library
|
||||
return new List<Folder>();
|
||||
}
|
||||
|
||||
return GetUserRootFolder().Children
|
||||
.OfType<Folder>()
|
||||
return GetCollectionFoldersInternal(item, GetUserRootFolder().Children.OfType<Folder>().ToList());
|
||||
}
|
||||
|
||||
public List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren)
|
||||
{
|
||||
while (item != null)
|
||||
{
|
||||
var parent = item.GetParent();
|
||||
|
||||
if (parent == null || parent is AggregateFolder)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
item = parent;
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
return new List<Folder>();
|
||||
}
|
||||
|
||||
return GetCollectionFoldersInternal(item, allUserRootChildren);
|
||||
}
|
||||
|
||||
private List<Folder> GetCollectionFoldersInternal(BaseItem item, List<Folder> allUserRootChildren)
|
||||
{
|
||||
return allUserRootChildren
|
||||
.Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path, StringComparer.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.IO;
|
||||
|
||||
namespace Emby.Server.Implementations.Library.Resolvers
|
||||
{
|
||||
@@ -13,11 +14,13 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
||||
{
|
||||
private readonly IImageProcessor _imageProcessor;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public PhotoResolver(IImageProcessor imageProcessor, ILibraryManager libraryManager)
|
||||
public PhotoResolver(IImageProcessor imageProcessor, ILibraryManager libraryManager, IFileSystem fileSystem)
|
||||
{
|
||||
_imageProcessor = imageProcessor;
|
||||
_libraryManager = libraryManager;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,7 +44,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
||||
var filename = Path.GetFileNameWithoutExtension(args.Path);
|
||||
|
||||
// Make sure the image doesn't belong to a video file
|
||||
if (args.DirectoryService.GetFilePaths(Path.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(args.GetLibraryOptions(), i, filename)))
|
||||
if (args.DirectoryService.GetFilePaths(_fileSystem.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(args.GetLibraryOptions(), i, filename)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -965,7 +965,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var path = GetPolifyFilePath(user);
|
||||
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
|
||||
lock (_policySyncLock)
|
||||
{
|
||||
@@ -1052,7 +1052,7 @@ namespace Emby.Server.Implementations.Library
|
||||
config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);
|
||||
}
|
||||
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
|
||||
lock (_configSyncLock)
|
||||
{
|
||||
|
||||
@@ -1497,7 +1497,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
|
||||
_libraryManager.RegisterIgnoredPath(recordPath);
|
||||
_libraryMonitor.ReportFileSystemChangeBeginning(recordPath);
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(recordPath));
|
||||
activeRecordingInfo.Path = recordPath;
|
||||
|
||||
var duration = recordingEndDate - DateTime.UtcNow;
|
||||
@@ -1725,7 +1725,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
|
||||
while (FileExists(path, timerId))
|
||||
{
|
||||
var parent = Path.GetDirectoryName(originalPath);
|
||||
var parent = _fileSystem.GetDirectoryName(originalPath);
|
||||
var name = Path.GetFileNameWithoutExtension(originalPath);
|
||||
name += "-" + index.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
@@ -1892,7 +1892,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
return;
|
||||
}
|
||||
|
||||
var imageSavePath = Path.Combine(Path.GetDirectoryName(recordingPath), imageSaveFilenameWithoutExtension);
|
||||
var imageSavePath = Path.Combine(_fileSystem.GetDirectoryName(recordingPath), imageSaveFilenameWithoutExtension);
|
||||
|
||||
// preserve original image extension
|
||||
imageSavePath = Path.ChangeExtension(imageSavePath, Path.GetExtension(image.Path));
|
||||
@@ -2545,7 +2545,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
private void SaveEpgDataForChannel(string channelId, List<ProgramInfo> epgData)
|
||||
{
|
||||
var path = GetChannelEpgCachePath(channelId);
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
lock (_epgLock)
|
||||
{
|
||||
_jsonSerializer.SerializeToFile(epgData, path);
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
private Task RecordFromFile(MediaSourceInfo mediaSource, string inputFile, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
|
||||
{
|
||||
_targetPath = targetFile;
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(targetFile));
|
||||
|
||||
var process = _processFactory.Create(new ProcessOptions
|
||||
{
|
||||
@@ -134,7 +134,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
_logger.Info(commandLineLogMessage);
|
||||
|
||||
var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "record-transcode-" + Guid.NewGuid() + ".txt");
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(logFilePath));
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
}
|
||||
|
||||
var file = _dataPath + ".json";
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(file));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(file));
|
||||
|
||||
lock (_fileDataLock)
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFile));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFile));
|
||||
|
||||
using (var stream = _fileSystem.OpenRead(tempFile))
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.Logging
|
||||
_logManager.Flush();
|
||||
|
||||
var path = Path.Combine(_appPaths.LogDirectoryPath, "unhandled_" + Guid.NewGuid() + ".txt");
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
|
||||
var builder = LogHelper.GetLogMessage(ex);
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.MediaEncoder
|
||||
|
||||
var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, video.PlayableStreamFileNames);
|
||||
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
|
||||
var container = video.Container;
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
{
|
||||
previouslyFailedImages.Add(key);
|
||||
|
||||
var parentPath = Path.GetDirectoryName(failHistoryPath);
|
||||
var parentPath = _fileSystem.GetDirectoryName(failHistoryPath);
|
||||
|
||||
_fileSystem.CreateDirectory(parentPath);
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Emby.Server.Implementations.Security
|
||||
}
|
||||
|
||||
var licenseFile = Filename;
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(licenseFile));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(licenseFile));
|
||||
lock (_fileLock)
|
||||
{
|
||||
_fileSystem.WriteAllLines(licenseFile, lines);
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace Emby.Server.Implementations.Updates
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(PackageCachePath));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(PackageCachePath));
|
||||
|
||||
_fileSystem.CopyFile(tempFile, PackageCachePath, true);
|
||||
_lastPackageUpdateTime = DateTime.UtcNow;
|
||||
@@ -627,7 +627,7 @@ namespace Emby.Server.Implementations.Updates
|
||||
// Success - move it to the real target
|
||||
try
|
||||
{
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(target));
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(target));
|
||||
_fileSystem.CopyFile(tempFile, target, true);
|
||||
//If it is an archive - write out a version file so we know what it is
|
||||
if (isArchive)
|
||||
|
||||
Reference in New Issue
Block a user