mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-01-09 18:26:19 +00:00
New: Auto rescan on remote path mapping change for Calibre
This commit is contained in:
@@ -7,9 +7,12 @@ using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Datastore.Events;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
||||
namespace NzbDrone.Core.RootFolders
|
||||
{
|
||||
@@ -26,7 +29,7 @@ namespace NzbDrone.Core.RootFolders
|
||||
string GetBestRootFolderPath(string path);
|
||||
}
|
||||
|
||||
public class RootFolderService : IRootFolderService
|
||||
public class RootFolderService : IRootFolderService, IHandle<ModelEvent<RemotePathMapping>>
|
||||
{
|
||||
private readonly IRootFolderRepository _rootFolderRepository;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
@@ -171,5 +174,20 @@ namespace NzbDrone.Core.RootFolders
|
||||
}
|
||||
}).Wait(5000);
|
||||
}
|
||||
|
||||
public void Handle(ModelEvent<RemotePathMapping> message)
|
||||
{
|
||||
var commands = All()
|
||||
.Where(x => x.IsCalibreLibrary &&
|
||||
x.CalibreSettings.Host == message.Model.Host &&
|
||||
x.Path.StartsWith(message.Model.LocalPath))
|
||||
.Select(x => new RescanFoldersCommand(new List<string> { x.Path }, FilterFilesType.None, true, null))
|
||||
.ToList();
|
||||
|
||||
if (commands.Any())
|
||||
{
|
||||
_commandQueueManager.PushMany(commands);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user