diff options
Diffstat (limited to 'Emby.Server.Implementations/Library/ResolverHelper.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/ResolverHelper.cs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Emby.Server.Implementations/Library/ResolverHelper.cs b/Emby.Server.Implementations/Library/ResolverHelper.cs index ac75e5d3a..7a61e2607 100644 --- a/Emby.Server.Implementations/Library/ResolverHelper.cs +++ b/Emby.Server.Implementations/Library/ResolverHelper.cs @@ -20,17 +20,15 @@ namespace Emby.Server.Implementations.Library /// <param name="parent">The parent.</param> /// <param name="libraryManager">The library manager.</param> /// <param name="directoryService">The directory service.</param> + /// <returns>True if initializing was successful.</returns> /// <exception cref="ArgumentException">Item must have a path.</exception> - public static void SetInitialItemValues(BaseItem item, Folder? parent, ILibraryManager libraryManager, IDirectoryService directoryService) + public static bool SetInitialItemValues(BaseItem item, Folder? parent, ILibraryManager libraryManager, IDirectoryService directoryService) { // This version of the below method has no ItemResolveArgs, so we have to require the path already being set - if (string.IsNullOrEmpty(item.Path)) - { - throw new ArgumentException("Item must have a Path"); - } + ArgumentException.ThrowIfNullOrEmpty(item.Path); // If the resolver didn't specify this - if (parent != null) + if (parent is not null) { item.SetParent(parent); } @@ -42,14 +40,16 @@ namespace Emby.Server.Implementations.Library // Make sure DateCreated and DateModified have values var fileInfo = directoryService.GetFile(item.Path); - if (fileInfo == null) + if (fileInfo is null) { - throw new FileNotFoundException("Can't find item path.", item.Path); + return false; } SetDateCreated(item, fileInfo); EnsureName(item, fileInfo); + + return true; } /// <summary> @@ -68,7 +68,7 @@ namespace Emby.Server.Implementations.Library } // If the resolver didn't specify this - if (args.Parent != null) + if (args.Parent is not null) { item.SetParent(args.Parent); } @@ -110,7 +110,7 @@ namespace Emby.Server.Implementations.Library { var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null; - if (childData != null) + if (childData is not null) { SetDateCreated(item, childData); } @@ -137,7 +137,7 @@ namespace Emby.Server.Implementations.Library if (config.UseFileCreationTimeForDateAdded) { // directoryService.getFile may return null - if (info != null) + if (info is not null) { var dateCreated = info.CreationTimeUtc; |
