mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-31 12:58:28 +01:00
Use ArgumentException.ThrowIfNullOrEmpty
This commit is contained in:
@@ -495,11 +495,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
private Guid GetNewItemIdInternal(string key, Type type, bool forceCaseInsensitive)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(key);
|
||||
ArgumentNullException.ThrowIfNull(type);
|
||||
|
||||
string programDataPath = _configurationManager.ApplicationPaths.ProgramDataPath;
|
||||
@@ -818,10 +814,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
// If this returns multiple items it could be tricky figuring out which one is correct.
|
||||
// In most cases, the newest one will be and the others obsolete but not yet cleaned up
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(path);
|
||||
|
||||
var query = new InternalItemsQuery
|
||||
{
|
||||
@@ -2340,10 +2333,7 @@ namespace Emby.Server.Implementations.Library
|
||||
string sortName,
|
||||
string uniqueId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(name);
|
||||
|
||||
var parentIdString = parentId.Equals(default)
|
||||
? null
|
||||
@@ -3125,10 +3115,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public void RemoveMediaPath(string virtualFolderName, string mediaPath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(mediaPath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(mediaPath));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(mediaPath);
|
||||
|
||||
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
|
||||
|
||||
@@ -762,10 +762,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetLiveStreamWithDirectStreamProvider(string id, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(id);
|
||||
|
||||
// TODO probably shouldn't throw here but it is kept for "backwards compatibility"
|
||||
var info = GetLiveStreamInfo(id) ?? throw new ResourceNotFoundException();
|
||||
@@ -774,10 +771,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public ILiveStream GetLiveStreamInfo(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(id);
|
||||
|
||||
if (_openStreams.TryGetValue(id, out ILiveStream info))
|
||||
{
|
||||
@@ -801,10 +795,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public async Task CloseLiveStream(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(id);
|
||||
|
||||
await _liveStreamSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
|
||||
@@ -835,10 +826,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
private (IMediaSourceProvider MediaSourceProvider, string KeyId) GetProvider(string key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
throw new ArgumentException("Key can't be empty.", nameof(key));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(key);
|
||||
|
||||
var keys = key.Split(LiveStreamIdDelimeter, 2);
|
||||
|
||||
|
||||
@@ -25,10 +25,7 @@ namespace Emby.Server.Implementations.Library
|
||||
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 is not null)
|
||||
|
||||
@@ -73,10 +73,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
var searchTerm = query.SearchTerm;
|
||||
|
||||
if (string.IsNullOrEmpty(searchTerm))
|
||||
{
|
||||
throw new ArgumentException("SearchTerm can't be empty.", nameof(query));
|
||||
}
|
||||
ArgumentException.ThrowIfNullOrEmpty(searchTerm);
|
||||
|
||||
searchTerm = searchTerm.Trim().RemoveDiacritics();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user