mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-25 15:22:42 +00:00
New: Split out metadata refresh from disk rescan
This commit is contained in:
parent
a2ba8e76bb
commit
95cfa0d09a
7 changed files with 23 additions and 23 deletions
|
@ -11,6 +11,7 @@
|
|||
using NzbDrone.Core.ImportLists;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Music.Commands;
|
||||
|
@ -65,6 +66,7 @@ public void Handle(ApplicationStartedEvent message)
|
|||
new ScheduledTask { Interval = 6 * 60, TypeName = typeof(ApplicationUpdateCommand).FullName },
|
||||
new ScheduledTask { Interval = 6 * 60, TypeName = typeof(CheckHealthCommand).FullName },
|
||||
new ScheduledTask { Interval = 24 * 60, TypeName = typeof(RefreshArtistCommand).FullName },
|
||||
new ScheduledTask { Interval = 24 * 60, TypeName = typeof(RescanFoldersCommand).FullName },
|
||||
new ScheduledTask { Interval = 24 * 60, TypeName = typeof(HousekeepingCommand).FullName },
|
||||
|
||||
new ScheduledTask
|
||||
|
|
|
@ -7,17 +7,22 @@ public class RescanFoldersCommand : Command
|
|||
{
|
||||
public RescanFoldersCommand()
|
||||
{
|
||||
// These are the settings used in the scheduled task
|
||||
Filter = FilterFilesType.Known;
|
||||
AddNewArtists = true;
|
||||
}
|
||||
|
||||
public RescanFoldersCommand(List<string> folders, FilterFilesType filter, List<int> artistIds)
|
||||
public RescanFoldersCommand(List<string> folders, FilterFilesType filter, bool addNewArtists, List<int> artistIds)
|
||||
{
|
||||
Folders = folders;
|
||||
Filter = filter;
|
||||
AddNewArtists = addNewArtists;
|
||||
ArtistIds = artistIds;
|
||||
}
|
||||
|
||||
public List<string> Folders { get; set; }
|
||||
public FilterFilesType Filter { get; set; }
|
||||
public bool AddNewArtists { get; set; }
|
||||
public List<int> ArtistIds { get; set; }
|
||||
|
||||
public override bool SendUpdatesToClient => true;
|
||||
|
|
|
@ -16,14 +16,13 @@
|
|||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles
|
||||
{
|
||||
public interface IDiskScanService
|
||||
{
|
||||
void Scan(List<string> folders = null, FilterFilesType filter = FilterFilesType.Known, List<int> artistIds = null);
|
||||
void Scan(List<string> folders = null, FilterFilesType filter = FilterFilesType.Known, bool addNewArtists = false, List<int> artistIds = null);
|
||||
IFileInfo[] GetAudioFiles(string path, bool allDirectories = true);
|
||||
string[] GetNonAudioFiles(string path, bool allDirectories = true);
|
||||
List<IFileInfo> FilterFiles(string basePath, IEnumerable<IFileInfo> files);
|
||||
|
@ -68,7 +67,7 @@ public DiskScanService(IDiskProvider diskProvider,
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Scan(List<string> folders = null, FilterFilesType filter = FilterFilesType.Known, List<int> artistIds = null)
|
||||
public void Scan(List<string> folders = null, FilterFilesType filter = FilterFilesType.Known, bool addNewArtists = false, List<int> artistIds = null)
|
||||
{
|
||||
if (folders == null)
|
||||
{
|
||||
|
@ -145,7 +144,7 @@ public void Scan(List<string> folders = null, FilterFilesType filter = FilterFil
|
|||
{
|
||||
Filter = filter,
|
||||
IncludeExisting = true,
|
||||
AddNewArtists = true
|
||||
AddNewArtists = addNewArtists
|
||||
};
|
||||
|
||||
var decisions = _importDecisionMaker.GetImportDecisions(mediaFileList, null, null, config);
|
||||
|
@ -275,7 +274,7 @@ public List<IFileInfo> FilterFiles(string basePath, IEnumerable<IFileInfo> files
|
|||
|
||||
public void Execute(RescanFoldersCommand message)
|
||||
{
|
||||
Scan(message.Folders, message.Filter, message.ArtistIds);
|
||||
Scan(message.Folders, message.Filter, message.AddNewArtists, message.ArtistIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
@ -33,7 +34,7 @@ public void Handle(AlbumEditedEvent message)
|
|||
tracks.ForEach(x => x.TrackFileId = 0);
|
||||
_trackService.SetFileIds(tracks);
|
||||
|
||||
_commandQueueManager.Push(new RescanFoldersCommand());
|
||||
_commandQueueManager.Push(new RescanFoldersCommand(null, FilterFilesType.Matched, false, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ public bool RefreshAlbumInfo(List<Album> albums, List<Album> remoteAlbums, bool
|
|||
{
|
||||
bool updated = false;
|
||||
|
||||
var updatedMusicbrainzAlbums = new HashSet<string>();
|
||||
HashSet<string> updatedMusicbrainzAlbums = null;
|
||||
|
||||
if (lastUpdate.HasValue && lastUpdate.Value.AddDays(14) > DateTime.UtcNow)
|
||||
{
|
||||
|
|
|
@ -285,26 +285,19 @@ private void Rescan(List<int> artistIds, bool isNew, CommandTrigger trigger, boo
|
|||
_logger.Trace("Skipping rescan. Reason: not after automatic refreshes");
|
||||
shouldRescan = false;
|
||||
}
|
||||
|
||||
if (!shouldRescan)
|
||||
else if (!infoUpdated)
|
||||
{
|
||||
return;
|
||||
_logger.Trace("Skipping rescan. Reason: no metadata updated");
|
||||
shouldRescan = false;
|
||||
}
|
||||
|
||||
try
|
||||
if (shouldRescan)
|
||||
{
|
||||
// If some metadata has been updated then rescan unmatched files.
|
||||
// Otherwise only scan files that haven't been seen before.
|
||||
var filter = infoUpdated ? FilterFilesType.Matched : FilterFilesType.Known;
|
||||
_logger.Trace($"InfoUpdated: {infoUpdated}, using scan filter {filter}");
|
||||
|
||||
// some metadata has updated so rescan unmatched
|
||||
// (but don't add new artists to reduce repeated searches against api)
|
||||
var folders = _rootFolderService.All().Select(x => x.Path).ToList();
|
||||
|
||||
_commandQueueManager.Push(new RescanFoldersCommand(folders, filter, artistIds));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e, "Couldn't rescan");
|
||||
_commandQueueManager.Push(new RescanFoldersCommand(folders, FilterFilesType.Matched, false, artistIds));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ public RootFolder Add(RootFolder rootFolder)
|
|||
|
||||
_rootFolderRepository.Insert(rootFolder);
|
||||
|
||||
_commandQueueManager.Push(new RescanFoldersCommand(new List<string> { rootFolder.Path }, FilterFilesType.None, null));
|
||||
_commandQueueManager.Push(new RescanFoldersCommand(new List<string> { rootFolder.Path }, FilterFilesType.None, true, null));
|
||||
|
||||
GetDetails(rootFolder);
|
||||
|
||||
|
|
Loading…
Reference in a new issue