Fixed: Validate calibre connection before saving root folder

pull/380/head
ta264 5 years ago
parent d2fa75dee5
commit 8781b78be9

@ -2,11 +2,15 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using NLog; using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Books.Calibre;
using NzbDrone.Core.Exceptions;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.Commands;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
@ -30,16 +34,19 @@ namespace NzbDrone.Core.RootFolders
{ {
private readonly IRootFolderRepository _rootFolderRepository; private readonly IRootFolderRepository _rootFolderRepository;
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
private readonly ICalibreProxy _calibreProxy;
private readonly IManageCommandQueue _commandQueueManager; private readonly IManageCommandQueue _commandQueueManager;
private readonly Logger _logger; private readonly Logger _logger;
public RootFolderService(IRootFolderRepository rootFolderRepository, public RootFolderService(IRootFolderRepository rootFolderRepository,
ICalibreProxy calibreProxy,
IDiskProvider diskProvider, IDiskProvider diskProvider,
IManageCommandQueue commandQueueManager, IManageCommandQueue commandQueueManager,
Logger logger) Logger logger)
{ {
_rootFolderRepository = rootFolderRepository; _rootFolderRepository = rootFolderRepository;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_calibreProxy = calibreProxy;
_commandQueueManager = commandQueueManager; _commandQueueManager = commandQueueManager;
_logger = logger; _logger = logger;
} }
@ -91,6 +98,12 @@ namespace NzbDrone.Core.RootFolders
{ {
throw new UnauthorizedAccessException(string.Format("Root folder path '{0}' is not writable by user '{1}'", rootFolder.Path, Environment.UserName)); throw new UnauthorizedAccessException(string.Format("Root folder path '{0}' is not writable by user '{1}'", rootFolder.Path, Environment.UserName));
} }
if (rootFolder.IsCalibreLibrary)
{
// This will throw on failure
_calibreProxy.GetLibraryInfo(rootFolder.CalibreSettings);
}
} }
public RootFolder Add(RootFolder rootFolder) public RootFolder Add(RootFolder rootFolder)

Loading…
Cancel
Save