aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/LibraryManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Library/LibraryManager.cs')
-rw-r--r--Emby.Server.Implementations/Library/LibraryManager.cs117
1 files changed, 43 insertions, 74 deletions
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index ad070ed79..064006ebd 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -375,7 +375,7 @@ namespace Emby.Server.Implementations.Library
try
{
- _fileSystem.DeleteDirectory(metadataPath, true);
+ Directory.Delete(metadataPath, true);
}
catch (IOException)
{
@@ -395,38 +395,33 @@ namespace Emby.Server.Implementations.Library
foreach (var fileSystemInfo in item.GetDeletePaths().ToList())
{
- try
+ if (File.Exists(fileSystemInfo.FullName))
{
- _logger.LogDebug("Deleting path {path}", fileSystemInfo.FullName);
- if (fileSystemInfo.IsDirectory)
- {
- _fileSystem.DeleteDirectory(fileSystemInfo.FullName, true);
- }
- else
+ try
{
- _fileSystem.DeleteFile(fileSystemInfo.FullName);
+ _logger.LogDebug("Deleting path {path}", fileSystemInfo.FullName);
+ if (fileSystemInfo.IsDirectory)
+ {
+ Directory.Delete(fileSystemInfo.FullName, true);
+ }
+ else
+ {
+ File.Delete(fileSystemInfo.FullName);
+ }
}
- }
- catch (FileNotFoundException)
- {
- // may have already been deleted manually by user
- }
- catch (DirectoryNotFoundException)
- {
- // may have already been deleted manually by user
- }
- catch (IOException)
- {
- if (isRequiredForDelete)
+ catch (IOException)
{
- throw;
+ if (isRequiredForDelete)
+ {
+ throw;
+ }
}
- }
- catch (UnauthorizedAccessException)
- {
- if (isRequiredForDelete)
+ catch (UnauthorizedAccessException)
{
- throw;
+ if (isRequiredForDelete)
+ {
+ throw;
+ }
}
}
@@ -517,7 +512,7 @@ namespace Emby.Server.Implementations.Library
if (forceCaseInsensitive || !ConfigurationManager.Configuration.EnableCaseSensitiveItemIds)
{
- key = key.ToLower();
+ key = key.ToLowerInvariant();
}
key = type.FullName + key;
@@ -725,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>();
@@ -739,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
{
@@ -790,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;
@@ -874,11 +869,6 @@ namespace Emby.Server.Implementations.Library
return GetItemByNameId<MusicGenre>(MusicGenre.GetPath, name);
}
- public Guid GetGameGenreId(string name)
- {
- return GetItemByNameId<GameGenre>(GameGenre.GetPath, name);
- }
-
/// <summary>
/// Gets a Genre
/// </summary>
@@ -900,16 +890,6 @@ namespace Emby.Server.Implementations.Library
}
/// <summary>
- /// Gets the game genre.
- /// </summary>
- /// <param name="name">The name.</param>
- /// <returns>Task{GameGenre}.</returns>
- public GameGenre GetGameGenre(string name)
- {
- return CreateItemByName<GameGenre>(GameGenre.GetPath, name, new DtoOptions(true));
- }
-
- /// <summary>
/// Gets a Year
/// </summary>
/// <param name="value">The value.</param>
@@ -1004,7 +984,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);
}
@@ -1233,7 +1213,7 @@ namespace Emby.Server.Implementations.Library
private string GetCollectionType(string path)
{
return _fileSystem.GetFilePaths(path, new[] { ".collection" }, true, false)
- .Select(i => _fileSystem.GetFileNameWithoutExtension(i))
+ .Select(i => Path.GetFileNameWithoutExtension(i))
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
}
@@ -1375,17 +1355,6 @@ namespace Emby.Server.Implementations.Library
return ItemRepository.GetGenres(query);
}
- public QueryResult<Tuple<BaseItem, ItemCounts>> GetGameGenres(InternalItemsQuery query)
- {
- if (query.User != null)
- {
- AddUserToQuery(query, query.User);
- }
-
- SetTopParentOrAncestorIds(query);
- return ItemRepository.GetGameGenres(query);
- }
-
public QueryResult<Tuple<BaseItem, ItemCounts>> GetMusicGenres(InternalItemsQuery query)
{
if (query.User != null)
@@ -2151,7 +2120,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
{
@@ -2196,7 +2165,7 @@ namespace Emby.Server.Implementations.Library
if (item == null)
{
- _fileSystem.CreateDirectory(path);
+ Directory.CreateDirectory(path);
item = new UserView
{
@@ -2261,7 +2230,7 @@ namespace Emby.Server.Implementations.Library
if (item == null)
{
- _fileSystem.CreateDirectory(path);
+ Directory.CreateDirectory(path);
item = new UserView
{
@@ -2329,7 +2298,7 @@ namespace Emby.Server.Implementations.Library
if (item == null)
{
- _fileSystem.CreateDirectory(path);
+ Directory.CreateDirectory(path);
item = new UserView
{
@@ -2868,7 +2837,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);
@@ -2877,7 +2846,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 + ".");
@@ -2888,13 +2857,13 @@ namespace Emby.Server.Implementations.Library
try
{
- _fileSystem.CreateDirectory(virtualFolderPath);
+ Directory.CreateDirectory(virtualFolderPath);
if (!string.IsNullOrEmpty(collectionType))
{
var path = Path.Combine(virtualFolderPath, collectionType + ".collection");
- _fileSystem.WriteAllBytes(path, Array.Empty<byte>());
+ File.WriteAllBytes(path, Array.Empty<byte>());
}
CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
@@ -2940,7 +2909,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);
// }
//}
@@ -2968,7 +2937,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.");
}
@@ -2981,11 +2950,11 @@ namespace Emby.Server.Implementations.Library
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
- var shortcutFilename = _fileSystem.GetFileNameWithoutExtension(path);
+ var shortcutFilename = Path.GetFileNameWithoutExtension(path);
var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
- while (_fileSystem.FileExists(lnk))
+ while (File.Exists(lnk))
{
shortcutFilename += "1";
lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
@@ -3078,7 +3047,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");
}
@@ -3087,7 +3056,7 @@ namespace Emby.Server.Implementations.Library
try
{
- _fileSystem.DeleteDirectory(path, true);
+ Directory.Delete(path, true);
}
finally
{
@@ -3150,7 +3119,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));
}