Unwrapped MoveDirectory, DirectoryExists, FileExists & removed MoveFile

This commit is contained in:
Erwin de Haan
2019-01-26 22:59:53 +01:00
parent a430568082
commit 581a7fe078
38 changed files with 89 additions and 87 deletions

View File

@@ -197,7 +197,7 @@ namespace Emby.Server.Implementations.AppBase
&& !string.Equals(CommonConfiguration.CachePath ?? string.Empty, newPath))
{
// Validate
if (!FileSystem.DirectoryExists(newPath))
if (!Directory.Exists(newPath))
{
throw new FileNotFoundException(string.Format("{0} does not exist.", newPath));
}

View File

@@ -1008,7 +1008,7 @@ namespace Emby.Server.Implementations
try
{
if (!FileSystemManager.FileExists(certificateLocation))
if (!File.Exists(certificateLocation))
{
return null;
}
@@ -1434,7 +1434,7 @@ namespace Emby.Server.Implementations
//if (generateCertificate)
//{
// if (!FileSystemManager.FileExists(certPath))
// if (!File.Exists(certPath))
// {
// FileSystemManager.CreateDirectory(FileSystemManager.GetDirectoryName(certPath));

View File

@@ -359,7 +359,7 @@ namespace Emby.Server.Implementations.Collections
{
var path = _collectionManager.GetCollectionsFolderPath();
if (_fileSystem.DirectoryExists(path))
if (Directory.Exists(path))
{
try
{

View File

@@ -148,7 +148,7 @@ namespace Emby.Server.Implementations.Configuration
&& !string.Equals(Configuration.CertificatePath ?? string.Empty, newPath))
{
// Validate
if (!FileSystem.FileExists(newPath))
if (!File.Exists(newPath))
{
throw new FileNotFoundException(string.Format("Certificate file '{0}' does not exist.", newPath));
}
@@ -168,7 +168,7 @@ namespace Emby.Server.Implementations.Configuration
&& !string.Equals(Configuration.MetadataPath ?? string.Empty, newPath))
{
// Validate
if (!FileSystem.DirectoryExists(newPath))
if (!Directory.Exists(newPath))
{
throw new FileNotFoundException(string.Format("{0} does not exist.", newPath));
}

View File

@@ -431,7 +431,7 @@ namespace Emby.Server.Implementations.Devices
{
var path = _deviceManager.GetUploadsPath();
if (_fileSystem.DirectoryExists(path))
if (Directory.Exists(path))
{
try
{

View File

@@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.FFMpeg
var prebuiltFolder = _appPaths.ProgramSystemPath;
var prebuiltffmpeg = Path.Combine(prebuiltFolder, downloadInfo.FFMpegFilename);
var prebuiltffprobe = Path.Combine(prebuiltFolder, downloadInfo.FFProbeFilename);
if (_fileSystem.FileExists(prebuiltffmpeg) && _fileSystem.FileExists(prebuiltffprobe))
if (File.Exists(prebuiltffmpeg) && File.Exists(prebuiltffprobe))
{
return new FFMpegInfo
{
@@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.FFMpeg
var excludeFromDeletions = new List<string> { versionedDirectoryPath };
if (!_fileSystem.FileExists(info.ProbePath) || !_fileSystem.FileExists(info.EncoderPath))
if (!File.Exists(info.ProbePath) || !File.Exists(info.EncoderPath))
{
// ffmpeg not present. See if there's an older version we can start with
var existingVersion = GetExistingVersion(info, rootEncoderPath);

View File

@@ -195,7 +195,7 @@ namespace Emby.Server.Implementations.IO
if (item != null)
{
// If the item has been deleted find the first valid parent that still exists
while (!_fileSystem.DirectoryExists(item.Path) && !_fileSystem.FileExists(item.Path))
while (!Directory.Exists(item.Path) && !File.Exists(item.Path))
{
item = item.GetOwner() ?? item.GetParent();

View File

@@ -277,7 +277,7 @@ namespace Emby.Server.Implementations.IO
/// <param name="path">The path.</param>
private void StartWatchingPath(string path)
{
if (!_fileSystem.DirectoryExists(path))
if (!Directory.Exists(path))
{
// Seeing a crash in the mono runtime due to an exception being thrown on a different thread
Logger.LogInformation("Skipping realtime monitor for {0} because the path does not exist", path);

View File

@@ -2863,7 +2863,7 @@ namespace Emby.Server.Implementations.Library
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, name);
while (_fileSystem.DirectoryExists(virtualFolderPath))
while (Directory.Exists(virtualFolderPath))
{
name += "1";
virtualFolderPath = Path.Combine(rootFolderPath, name);
@@ -2872,7 +2872,7 @@ namespace Emby.Server.Implementations.Library
var mediaPathInfos = options.PathInfos;
if (mediaPathInfos != null)
{
var invalidpath = mediaPathInfos.FirstOrDefault(i => !_fileSystem.DirectoryExists(i.Path));
var invalidpath = mediaPathInfos.FirstOrDefault(i => !Directory.Exists(i.Path));
if (invalidpath != null)
{
throw new ArgumentException("The specified path does not exist: " + invalidpath.Path + ".");
@@ -2935,7 +2935,7 @@ namespace Emby.Server.Implementations.Library
// // We can't validate protocol-based paths, so just allow them
// if (path.IndexOf("://", StringComparison.OrdinalIgnoreCase) == -1)
// {
// return _fileSystem.DirectoryExists(path);
// return Directory.Exists(path);
// }
//}
@@ -2963,7 +2963,7 @@ namespace Emby.Server.Implementations.Library
throw new ArgumentNullException(nameof(path));
}
if (!_fileSystem.DirectoryExists(path))
if (!Directory.Exists(path))
{
throw new FileNotFoundException("The path does not exist.");
}
@@ -2980,7 +2980,7 @@ namespace Emby.Server.Implementations.Library
var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
while (_fileSystem.FileExists(lnk))
while (File.Exists(lnk))
{
shortcutFilename += "1";
lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
@@ -3073,7 +3073,7 @@ namespace Emby.Server.Implementations.Library
var path = Path.Combine(rootFolderPath, name);
if (!_fileSystem.DirectoryExists(path))
if (!Directory.Exists(path))
{
throw new FileNotFoundException("The media folder does not exist");
}
@@ -3145,7 +3145,7 @@ namespace Emby.Server.Implementations.Library
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
if (!_fileSystem.DirectoryExists(virtualFolderPath))
if (!Directory.Exists(virtualFolderPath))
{
throw new FileNotFoundException(string.Format("The media collection {0} does not exist", virtualFolderName));
}

View File

@@ -1427,7 +1427,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
timer.RetryCount++;
_timerProvider.AddOrUpdate(timer);
}
else if (_fileSystem.FileExists(recordPath))
else if (File.Exists(recordPath))
{
timer.RecordingPath = recordPath;
timer.Status = RecordingStatus.Completed;
@@ -1573,7 +1573,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
.Where(i => i.Status == RecordingStatus.Completed && !string.IsNullOrWhiteSpace(i.RecordingPath))
.Where(i => string.Equals(i.SeriesTimerId, seriesTimerId, StringComparison.OrdinalIgnoreCase))
.OrderByDescending(i => i.EndDate)
.Where(i => _fileSystem.FileExists(i.RecordingPath))
.Where(i => File.Exists(i.RecordingPath))
.Skip(seriesTimer.KeepUpTo - 1)
.ToList();
@@ -1595,7 +1595,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
DtoOptions = new DtoOptions(true)
}))
.Where(i => i.IsFileProtocol && _fileSystem.FileExists(i.Path))
.Where(i => i.IsFileProtocol && File.Exists(i.Path))
.Skip(seriesTimer.KeepUpTo - 1)
.ToList();
@@ -1689,7 +1689,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private bool FileExists(string path, string timerId)
{
if (_fileSystem.FileExists(path))
if (File.Exists(path))
{
return true;
}
@@ -1961,7 +1961,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var nfoPath = Path.Combine(seriesPath, "tvshow.nfo");
if (_fileSystem.FileExists(nfoPath))
if (File.Exists(nfoPath))
{
return;
}
@@ -2023,7 +2023,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var nfoPath = Path.ChangeExtension(recordingPath, ".nfo");
if (_fileSystem.FileExists(nfoPath))
if (File.Exists(nfoPath))
{
return;
}
@@ -2688,7 +2688,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var defaultFolder = RecordingPath;
var defaultName = "Recordings";
if (_fileSystem.DirectoryExists(defaultFolder))
if (Directory.Exists(defaultFolder))
{
list.Add(new VirtualFolderInfo
{
@@ -2698,7 +2698,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
var customPath = GetConfiguration().MovieRecordingPath;
if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && _fileSystem.DirectoryExists(customPath))
if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && Directory.Exists(customPath))
{
list.Add(new VirtualFolderInfo
{
@@ -2709,7 +2709,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
customPath = GetConfiguration().SeriesRecordingPath;
if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && _fileSystem.DirectoryExists(customPath))
if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && Directory.Exists(customPath))
{
list.Add(new VirtualFolderInfo
{

View File

@@ -61,7 +61,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
string cacheFilename = DateTime.UtcNow.DayOfYear.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.UtcNow.Hour.ToString(CultureInfo.InvariantCulture) + ".xml";
string cacheFile = Path.Combine(_config.ApplicationPaths.CachePath, "xmltv", cacheFilename);
if (_fileSystem.FileExists(cacheFile))
if (File.Exists(cacheFile))
{
return UnzipIfNeeded(path, cacheFile);
}
@@ -255,7 +255,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
public Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings)
{
// Assume all urls are valid. check files for existence
if (!info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !_fileSystem.FileExists(info.Path))
if (!info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !File.Exists(info.Path))
{
throw new FileNotFoundException("Could not find the XmlTv file specified:", info.Path);
}

View File

@@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.Playlists
private string GetTargetPath(string path)
{
while (_fileSystem.DirectoryExists(path))
while (Directory.Exists(path))
{
path += "1";
}