Mediascan job doesn't scan series that aren't fully added to the db yet
This commit is contained in:
parent
c01595a9c4
commit
4ac4ba5067
|
@ -1,12 +1,17 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Linq;
|
||||||
using AutoMoq;
|
using AutoMoq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using MbUnit.Framework;
|
using MbUnit.Framework;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Moq.Linq;
|
using Moq.Linq;
|
||||||
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Providers.Core;
|
using NzbDrone.Core.Providers.Core;
|
||||||
|
using NzbDrone.Core.Providers.Jobs;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using NzbDrone.Core.Repository.Quality;
|
using NzbDrone.Core.Repository.Quality;
|
||||||
using SubSonic.Repository;
|
using SubSonic.Repository;
|
||||||
|
@ -285,5 +290,22 @@ namespace NzbDrone.Core.Test
|
||||||
mocker.VerifyAllMocks();
|
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 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||||
seriesToScan = new List<Series>() { _seriesProvider.GetSeries(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);
|
notification.CurrentMessage = string.Format("Scanning disk for '{0}'", series.Title);
|
||||||
_mediaFileProvider.Scan(series);
|
_mediaFileProvider.Scan(series);
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Providers
|
||||||
/// Scans the specified series folder for media files
|
/// Scans the specified series folder for media files
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name = "series">The series to be scanned</param>
|
/// <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 mediaFileList = GetMediaFileList(series.Path);
|
||||||
var fileList = new List<EpisodeFile>();
|
var fileList = new List<EpisodeFile>();
|
||||||
|
@ -51,7 +51,7 @@ namespace NzbDrone.Core.Providers
|
||||||
return fileList;
|
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);
|
Logger.Trace("Importing file to database [{0}]", filePath);
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ namespace NzbDrone.Core.Providers
|
||||||
/// Removes files that no longer exist from the database
|
/// Removes files that no longer exist from the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name = "files">list of files to verify</param>
|
/// <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.
|
//TODO: remove orphaned files. in files table but not linked to from episode table.
|
||||||
foreach (var episodeFile in files)
|
foreach (var episodeFile in files)
|
||||||
|
@ -165,17 +165,17 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void Update(EpisodeFile episodeFile)
|
public virtual void Update(EpisodeFile episodeFile)
|
||||||
{
|
{
|
||||||
_repository.Update(episodeFile);
|
_repository.Update(episodeFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EpisodeFile GetEpisodeFile(int episodeFileId)
|
public virtual EpisodeFile GetEpisodeFile(int episodeFileId)
|
||||||
{
|
{
|
||||||
return _repository.Single<EpisodeFile>(episodeFileId);
|
return _repository.Single<EpisodeFile>(episodeFileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EpisodeFile> GetEpisodeFiles()
|
public virtual List<EpisodeFile> GetEpisodeFiles()
|
||||||
{
|
{
|
||||||
return _repository.All<EpisodeFile>().ToList();
|
return _repository.All<EpisodeFile>().ToList();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue