mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-26 17:47:08 +00:00
Mediascan job doesn't scan series that aren't fully added to the db yet
This commit is contained in:
parent
c01595a9c4
commit
4ac4ba5067
3 changed files with 29 additions and 7 deletions
|
@ -1,12 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq.Expressions;
|
||||
using System.Linq;
|
||||
using AutoMoq;
|
||||
using FizzWare.NBuilder;
|
||||
using MbUnit.Framework;
|
||||
using Moq;
|
||||
using Moq.Linq;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using SubSonic.Repository;
|
||||
|
@ -285,5 +290,22 @@ public void scan_series_should_update_last_scan_date()
|
|||
mocker.VerifyAllMocks();
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void scan_media_job_should_not_scan_new_series()
|
||||
{
|
||||
var mocker = new AutoMoqer();
|
||||
mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.GetAllSeries())
|
||||
.Returns(Builder<Series>.CreateListOfSize(2)
|
||||
.WhereTheFirst(1).Has(c => c.LastInfoSync = DateTime.Now).Build().AsQueryable());
|
||||
mocker.GetMock<MediaFileProvider>( MockBehavior.Strict)
|
||||
.Setup(c=>c.Scan(It.Is<Series>(s=>s.LastInfoSync != null))).Returns(new List<EpisodeFile>()).Verifiable();
|
||||
|
||||
mocker.Resolve<MediaFileScanJob>().Start(new ProgressNotification("test"), 0);
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ public void Start(ProgressNotification notification, int targetId)
|
|||
seriesToScan = new List<Series>() { _seriesProvider.GetSeries(targetId) };
|
||||
}
|
||||
|
||||
foreach (var series in seriesToScan)
|
||||
foreach (var series in seriesToScan.Where(c => c.LastInfoSync != null))
|
||||
{
|
||||
notification.CurrentMessage = string.Format("Scanning disk for '{0}'", series.Title);
|
||||
_mediaFileProvider.Scan(series);
|
||||
|
|
|
@ -33,7 +33,7 @@ public MediaFileProvider() { }
|
|||
/// Scans the specified series folder for media files
|
||||
/// </summary>
|
||||
/// <param name = "series">The series to be scanned</param>
|
||||
public List<EpisodeFile> Scan(Series series)
|
||||
public virtual List<EpisodeFile> Scan(Series series)
|
||||
{
|
||||
var mediaFileList = GetMediaFileList(series.Path);
|
||||
var fileList = new List<EpisodeFile>();
|
||||
|
@ -51,7 +51,7 @@ public List<EpisodeFile> Scan(Series series)
|
|||
return fileList;
|
||||
}
|
||||
|
||||
public EpisodeFile ImportFile(Series series, string filePath)
|
||||
public virtual EpisodeFile ImportFile(Series series, string filePath)
|
||||
{
|
||||
Logger.Trace("Importing file to database [{0}]", filePath);
|
||||
|
||||
|
@ -150,7 +150,7 @@ public EpisodeFile ImportFile(Series series, string filePath)
|
|||
/// Removes files that no longer exist from the database
|
||||
/// </summary>
|
||||
/// <param name = "files">list of files to verify</param>
|
||||
public void CleanUp(List<EpisodeFile> files)
|
||||
public virtual void CleanUp(List<EpisodeFile> files)
|
||||
{
|
||||
//TODO: remove orphaned files. in files table but not linked to from episode table.
|
||||
foreach (var episodeFile in files)
|
||||
|
@ -165,17 +165,17 @@ public void CleanUp(List<EpisodeFile> files)
|
|||
|
||||
|
||||
|
||||
public void Update(EpisodeFile episodeFile)
|
||||
public virtual void Update(EpisodeFile episodeFile)
|
||||
{
|
||||
_repository.Update(episodeFile);
|
||||
}
|
||||
|
||||
public EpisodeFile GetEpisodeFile(int episodeFileId)
|
||||
public virtual EpisodeFile GetEpisodeFile(int episodeFileId)
|
||||
{
|
||||
return _repository.Single<EpisodeFile>(episodeFileId);
|
||||
}
|
||||
|
||||
public List<EpisodeFile> GetEpisodeFiles()
|
||||
public virtual List<EpisodeFile> GetEpisodeFiles()
|
||||
{
|
||||
return _repository.All<EpisodeFile>().ToList();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue