Unwrapped CreateDirectory and DeleteDirectory

This commit is contained in:
Erwin de Haan
2019-01-26 22:08:04 +01:00
parent 3a831994f6
commit d7c6d16250
58 changed files with 102 additions and 101 deletions

View File

@@ -127,7 +127,7 @@ namespace Emby.Server.Implementations.AppBase
Logger.LogInformation("Saving system configuration");
var path = CommonApplicationPaths.SystemConfigurationFilePath;
FileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_configurationSyncLock)
{
@@ -294,7 +294,7 @@ namespace Emby.Server.Implementations.AppBase
_configurations.AddOrUpdate(key, configuration, (k, v) => configuration);
var path = GetConfigurationFile(key);
FileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_configurationSyncLock)
{

View File

@@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.AppBase
// If the file didn't exist before, or if something has changed, re-save
if (buffer == null || !buffer.SequenceEqual(newBytes))
{
fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
// Save it after load in case we got new items
fileSystem.WriteAllBytes(path, newBytes);

View File

@@ -355,7 +355,7 @@ namespace Emby.Server.Implementations.Channels
return;
}
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
_jsonSerializer.SerializeToFile(mediaSources, path);
}
@@ -834,7 +834,7 @@ namespace Emby.Server.Implementations.Channels
{
try
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
_jsonSerializer.SerializeToFile(result, path);
}

View File

@@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Collections
return null;
}
_fileSystem.CreateDirectory(path);
Directory.CreateDirectory(path);
var libraryOptions = new LibraryOptions
{
@@ -133,7 +133,7 @@ namespace Emby.Server.Implementations.Collections
try
{
_fileSystem.CreateDirectory(path);
Directory.CreateDirectory(path);
var collection = new BoxSet
{

View File

@@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.Devices
{
var path = CachePath;
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_syncLock)
{

View File

@@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Devices
public void SaveCapabilities(string deviceId, ClientCapabilities capabilities)
{
var path = Path.Combine(GetDevicePath(deviceId), "capabilities.json");
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_capabilitiesSyncLock)
{
@@ -239,7 +239,7 @@ namespace Emby.Server.Implementations.Devices
path = Path.Combine(path, file.Name);
path = Path.ChangeExtension(path, MimeTypes.ToExtension(file.MimeType) ?? "jpg");
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
await EnsureLibraryFolder(uploadPathInfo.Item2, uploadPathInfo.Item3).ConfigureAwait(false);
@@ -275,7 +275,7 @@ namespace Emby.Server.Implementations.Devices
private void AddCameraUpload(string deviceId, LocalFileInfo file)
{
var path = Path.Combine(GetDevicePath(deviceId), "camerauploads.json");
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_cameraUploadSyncLock)
{
@@ -317,7 +317,7 @@ namespace Emby.Server.Implementations.Devices
return Task.CompletedTask;
}
_fileSystem.CreateDirectory(path);
Directory.CreateDirectory(path);
var libraryOptions = new LibraryOptions
{

View File

@@ -75,7 +75,7 @@ namespace Emby.Server.Implementations.FFMpeg
Version = version
};
_fileSystem.CreateDirectory(versionedDirectoryPath);
Directory.CreateDirectory(versionedDirectoryPath);
var excludeFromDeletions = new List<string> { versionedDirectoryPath };

View File

@@ -305,7 +305,7 @@ namespace Emby.Server.Implementations.HttpClientManager
private async Task CacheResponse(HttpResponseInfo response, string responseCachePath)
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(responseCachePath));
Directory.CreateDirectory(Path.GetDirectoryName(responseCachePath));
using (var fileStream = _fileSystem.GetFileStream(responseCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.None, true))
{
@@ -513,7 +513,7 @@ namespace Emby.Server.Implementations.HttpClientManager
{
ValidateParams(options);
_fileSystem.CreateDirectory(_appPaths.TempDirectory);
Directory.CreateDirectory(_appPaths.TempDirectory);
var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + ".tmp");

View File

@@ -99,7 +99,7 @@ namespace Emby.Server.Implementations.Images
CancellationToken cancellationToken)
{
var outputPathWithoutExtension = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid().ToString("N"));
FileSystem.CreateDirectory(Path.GetDirectoryName(outputPathWithoutExtension));
Directory.CreateDirectory(Path.GetDirectoryName(outputPathWithoutExtension));
string outputPath = CreateImage(item, itemsWithImages, outputPathWithoutExtension, imageType, 0);
if (string.IsNullOrEmpty(outputPath))
@@ -165,7 +165,7 @@ namespace Emby.Server.Implementations.Images
private string CreateCollage(BaseItem primaryItem, List<BaseItem> items, string outputPath, int width, int height)
{
FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
var options = new ImageCollageOptions
{

View File

@@ -375,7 +375,7 @@ namespace Emby.Server.Implementations.Library
try
{
_fileSystem.DeleteDirectory(metadataPath, true);
Directory.Delete(metadataPath, true);
}
catch (IOException)
{
@@ -402,11 +402,11 @@ namespace Emby.Server.Implementations.Library
_logger.LogDebug("Deleting path {path}", fileSystemInfo.FullName);
if (fileSystemInfo.IsDirectory)
{
_fileSystem.DeleteDirectory(fileSystemInfo.FullName, true);
Directory.Delete(fileSystemInfo.FullName, true);
}
else
{
_fileSystem.DeleteFile(fileSystemInfo.FullName);
File.Delete(fileSystemInfo.FullName);
}
}
catch (IOException)
@@ -720,7 +720,7 @@ namespace Emby.Server.Implementations.Library
{
var rootFolderPath = ConfigurationManager.ApplicationPaths.RootFolderPath;
_fileSystem.CreateDirectory(rootFolderPath);
Directory.CreateDirectory(rootFolderPath);
var rootFolder = GetItemById(GetNewItemId(rootFolderPath, typeof(AggregateFolder))) as AggregateFolder ?? ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(rootFolderPath))).DeepCopy<Folder, AggregateFolder>();
@@ -734,7 +734,7 @@ namespace Emby.Server.Implementations.Library
// Add in the plug-in folders
var path = Path.Combine(ConfigurationManager.ApplicationPaths.DataPath, "playlists");
_fileSystem.CreateDirectory(path);
Directory.CreateDirectory(path);
Folder folder = new PlaylistsFolder
{
@@ -785,7 +785,7 @@ namespace Emby.Server.Implementations.Library
{
var userRootPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
_fileSystem.CreateDirectory(userRootPath);
Directory.CreateDirectory(userRootPath);
var tmpItem = GetItemById(GetNewItemId(userRootPath, typeof(UserRootFolder))) as UserRootFolder;
@@ -999,7 +999,7 @@ namespace Emby.Server.Implementations.Library
public Task ValidatePeople(CancellationToken cancellationToken, IProgress<double> progress)
{
// Ensure the location is available.
_fileSystem.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath);
Directory.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath);
return new PeopleValidator(this, _logger, ConfigurationManager, _fileSystem).ValidatePeople(cancellationToken, progress);
}
@@ -2146,7 +2146,7 @@ namespace Emby.Server.Implementations.Library
if (item == null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
{
_fileSystem.CreateDirectory(path);
Directory.CreateDirectory(path);
item = new UserView
{
@@ -2191,7 +2191,7 @@ namespace Emby.Server.Implementations.Library
if (item == null)
{
_fileSystem.CreateDirectory(path);
Directory.CreateDirectory(path);
item = new UserView
{
@@ -2256,7 +2256,7 @@ namespace Emby.Server.Implementations.Library
if (item == null)
{
_fileSystem.CreateDirectory(path);
Directory.CreateDirectory(path);
item = new UserView
{
@@ -2324,7 +2324,7 @@ namespace Emby.Server.Implementations.Library
if (item == null)
{
_fileSystem.CreateDirectory(path);
Directory.CreateDirectory(path);
item = new UserView
{
@@ -2883,7 +2883,7 @@ namespace Emby.Server.Implementations.Library
try
{
_fileSystem.CreateDirectory(virtualFolderPath);
Directory.CreateDirectory(virtualFolderPath);
if (!string.IsNullOrEmpty(collectionType))
{
@@ -3082,7 +3082,7 @@ namespace Emby.Server.Implementations.Library
try
{
_fileSystem.DeleteDirectory(path, true);
Directory.Delete(path, true);
}
finally
{

View File

@@ -670,7 +670,7 @@ namespace Emby.Server.Implementations.Library
if (cacheFilePath != null)
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
_jsonSerializer.SerializeToFile(mediaInfo, cacheFilePath);
//_logger.LogDebug("Saved media info to {0}", cacheFilePath);

View File

@@ -1080,7 +1080,7 @@ namespace Emby.Server.Implementations.Library
var path = GetPolicyFilePath(user);
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_policySyncLock)
{
@@ -1176,7 +1176,7 @@ namespace Emby.Server.Implementations.Library
config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);
}
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_configSyncLock)
{

View File

@@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private async Task RecordFromDirectStreamProvider(IDirectStreamProvider directStreamProvider, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile));
Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
using (var output = _fileSystem.GetFileStream(targetFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
{
@@ -78,7 +78,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
_logger.LogInformation("Opened recording stream from tuner provider");
_fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile));
Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
using (var output = _fileSystem.GetFileStream(targetFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
{

View File

@@ -79,7 +79,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));
Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
var process = _processFactory.Create(new ProcessOptions
{
@@ -105,7 +105,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_logger.LogInformation(commandLineLogMessage);
var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "record-transcode-" + Guid.NewGuid() + ".txt");
_fileSystem.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.
_logFileStream = _fileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true);

View File

@@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
var file = _dataPath + ".json";
_fileSystem.CreateDirectory(Path.GetDirectoryName(file));
Directory.CreateDirectory(Path.GetDirectoryName(file));
lock (_fileDataLock)
{

View File

@@ -83,7 +83,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
}).ConfigureAwait(false);
_fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFile));
Directory.CreateDirectory(Path.GetDirectoryName(cacheFile));
_fileSystem.CopyFile(tempFile, cacheFile, true);
@@ -125,7 +125,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
using (var stream = _fileSystem.OpenRead(file))
{
string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString());
_fileSystem.CreateDirectory(tempFolder);
Directory.CreateDirectory(tempFolder);
_zipClient.ExtractFirstFileFromGz(stream, tempFolder, "data.xml");
@@ -138,7 +138,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
using (var stream = _fileSystem.OpenRead(file))
{
string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString());
_fileSystem.CreateDirectory(tempFolder);
Directory.CreateDirectory(tempFolder);
_zipClient.ExtractAllFromGz(stream, tempFolder, true);

View File

@@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
try
{
FileSystem.CreateDirectory(Path.GetDirectoryName(channelCacheFile));
Directory.CreateDirectory(Path.GetDirectoryName(channelCacheFile));
JsonSerializer.SerializeToFile(channels, channelCacheFile);
}
catch (IOException)

View File

@@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var uri = new Uri(mediaSource.Path);
var localPort = _networkManager.GetRandomUnusedUdpPort();
FileSystem.CreateDirectory(Path.GetDirectoryName(TempFilePath));
Directory.CreateDirectory(Path.GetDirectoryName(TempFilePath));
Logger.LogInformation("Opening HDHR UDP Live stream from {host}", uri.Host);

View File

@@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var url = mediaSource.Path;
FileSystem.CreateDirectory(Path.GetDirectoryName(TempFilePath));
Directory.CreateDirectory(Path.GetDirectoryName(TempFilePath));
var typeName = GetType().Name;
Logger.LogInformation("Opening " + typeName + " Live stream from {0}", url);

View File

@@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.Localization
var localizationPath = LocalizationPath;
_fileSystem.CreateDirectory(localizationPath);
Directory.CreateDirectory(localizationPath);
var existingFiles = GetRatingsFiles(localizationPath)
.Select(Path.GetFileName)

View File

@@ -141,7 +141,7 @@ namespace Emby.Server.Implementations.MediaEncoder
var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, Array.Empty<string>());
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
var container = video.Container;

View File

@@ -119,7 +119,7 @@ namespace Emby.Server.Implementations.Playlists
try
{
_fileSystem.CreateDirectory(path);
Directory.CreateDirectory(path);
var playlist = new Playlist
{

View File

@@ -141,7 +141,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
var parentPath = Path.GetDirectoryName(failHistoryPath);
_fileSystem.CreateDirectory(parentPath);
Directory.CreateDirectory(parentPath);
_fileSystem.WriteAllText(failHistoryPath, string.Join("|", previouslyFailedImages.ToArray()));
}

View File

@@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
_lastExecutionResult = value;
var path = GetHistoryFilePath();
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
lock (_lastExecutionResultSyncLock)
{
@@ -565,7 +565,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
var path = GetConfigurationFilePath();
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
JsonSerializer.SerializeToFile(triggers, path);
}

View File

@@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
{
try
{
_fileSystem.DeleteDirectory(directory, false);
Directory.Delete(directory, false);
}
catch (UnauthorizedAccessException ex)
{

View File

@@ -570,7 +570,7 @@ namespace Emby.Server.Implementations.Updates
// Success - move it to the real target
try
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(target));
Directory.CreateDirectory(Path.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)