mirror of https://github.com/lidarr/Lidarr
Fixed: Better import error messages
This commit is contained in:
parent
78fcf86294
commit
2abeec06fc
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace NzbDrone.Common.Disk
|
||||
{
|
||||
public class DestinationAlreadyExistsException : IOException
|
||||
{
|
||||
public DestinationAlreadyExistsException()
|
||||
{
|
||||
}
|
||||
|
||||
public DestinationAlreadyExistsException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public DestinationAlreadyExistsException(string message, int hresult) : base(message, hresult)
|
||||
{
|
||||
}
|
||||
|
||||
public DestinationAlreadyExistsException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected DestinationAlreadyExistsException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
@ -340,7 +340,7 @@ namespace NzbDrone.Common.Disk
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new IOException(string.Format("Destination already exists. [{0}] to [{1}]", sourcePath, targetPath));
|
||||
throw new DestinationAlreadyExistsException($"Destination {targetPath} already exists.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NzbDrone.Common.Exceptions
|
||||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Common.Disk
|
||||
{
|
||||
public class NotParentException : NzbDroneException
|
||||
{
|
|
@ -59,7 +59,7 @@ namespace NzbDrone.Common.Extensions
|
|||
{
|
||||
if (!parentPath.IsParentPath(childPath))
|
||||
{
|
||||
throw new Exceptions.NotParentException("{0} is not a child of {1}", childPath, parentPath);
|
||||
throw new NotParentException("{0} is not a child of {1}", childPath, parentPath);
|
||||
}
|
||||
|
||||
return childPath.Substring(parentPath.Length).Trim(Path.DirectorySeparatorChar);
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
<Compile Include="ConsoleService.cs" />
|
||||
<Compile Include="ConvertBase32.cs" />
|
||||
<Compile Include="Crypto\HashProvider.cs" />
|
||||
<Compile Include="Disk\DestinationAlreadyExistsException.cs" />
|
||||
<Compile Include="Disk\FileSystemLookupService.cs" />
|
||||
<Compile Include="Disk\DriveInfoMount.cs" />
|
||||
<Compile Include="Disk\IMount.cs" />
|
||||
|
@ -129,7 +130,7 @@
|
|||
<Compile Include="EnvironmentInfo\IRuntimeInfo.cs" />
|
||||
<Compile Include="EnvironmentInfo\RuntimeInfo.cs" />
|
||||
<Compile Include="EnvironmentInfo\StartupContext.cs" />
|
||||
<Compile Include="Exceptions\NotParentException.cs" />
|
||||
<Compile Include="Disk\NotParentException.cs" />
|
||||
<Compile Include="Exceptions\NzbDroneException.cs" />
|
||||
<Compile Include="Expansive\CircularReferenceException.cs" />
|
||||
<Compile Include="Expansive\Expansive.cs" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
@ -165,7 +166,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
if (!_diskProvider.FolderExists(rootFolder))
|
||||
{
|
||||
throw new DirectoryNotFoundException(string.Format("Root folder '{0}' was not found.", rootFolder));
|
||||
throw new TrackImport.RootFolderNotFoundException(string.Format("Root folder '{0}' was not found.", rootFolder));
|
||||
}
|
||||
|
||||
var changed = false;
|
||||
|
|
|
@ -127,6 +127,16 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
|
|||
_eventAggregator.PublishEvent(new TrackImportedEvent(localTrack, trackFile, oldFiles, newDownload, downloadClientItem));
|
||||
|
||||
}
|
||||
catch (RootFolderNotFoundException e)
|
||||
{
|
||||
_logger.Warn(e, "Couldn't import track " + localTrack);
|
||||
importResults.Add(new ImportResult(importDecision, "Failed to import track, Root folder missing."));
|
||||
}
|
||||
catch (DestinationAlreadyExistsException e)
|
||||
{
|
||||
_logger.Warn(e, "Couldn't import track " + localTrack);
|
||||
importResults.Add(new ImportResult(importDecision, "Failed to import track, Destination already exists."));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Warn(e, "Couldn't import track " + localTrack);
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.TrackImport
|
||||
{
|
||||
public class RootFolderNotFoundException : DirectoryNotFoundException
|
||||
{
|
||||
public RootFolderNotFoundException()
|
||||
{
|
||||
}
|
||||
|
||||
public RootFolderNotFoundException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public RootFolderNotFoundException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected RootFolderNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -652,6 +652,7 @@
|
|||
<Compile Include="MediaFiles\TrackImport\Manual\ManualImportItem.cs" />
|
||||
<Compile Include="MediaFiles\TrackImport\Manual\ManualImportService.cs" />
|
||||
<Compile Include="MediaFiles\TrackImport\Manual\ManuallyImportedFile.cs" />
|
||||
<Compile Include="MediaFiles\TrackImport\RootFolderNotFoundException.cs" />
|
||||
<Compile Include="MediaFiles\TrackImport\Specifications\FreeSpaceSpecification.cs" />
|
||||
<Compile Include="MediaFiles\TrackImport\Specifications\NotUnpackingSpecification.cs" />
|
||||
<Compile Include="MediaFiles\TrackImport\Specifications\SameFileSpecification.cs" />
|
||||
|
|
Loading…
Reference in New Issue