mirror of
https://github.com/Readarr/Readarr
synced 2025-12-20 23:35:13 +01:00
New: Auto rescan on remote path mapping change for Calibre
This commit is contained in:
parent
9be948b7cc
commit
2d7aa20448
1 changed files with 19 additions and 1 deletions
|
|
@ -7,9 +7,12 @@
|
|||
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 @@ public interface IRootFolderService
|
|||
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 @@ private void GetDetails(RootFolder rootFolder)
|
|||
}
|
||||
}).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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue