mirror of
https://github.com/Readarr/Readarr
synced 2026-03-06 12:43:22 +01:00
Fixed: Import highest quality file first, not largest size
This commit is contained in:
parent
b1e92e7f73
commit
1f22cae4f8
2 changed files with 35 additions and 2 deletions
|
|
@ -165,7 +165,40 @@ public void should_not_move_existing_files()
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_import_larger_files_first()
|
||||
public void should_import_higher_quality_files_first()
|
||||
{
|
||||
var lqDecision = _approvedDecisions.First();
|
||||
lqDecision.Item.Quality = new QualityModel(Quality.MOBI);
|
||||
lqDecision.Item.Size = 10.Megabytes();
|
||||
|
||||
var hqDecision = new ImportDecision<LocalBook>(
|
||||
new LocalBook
|
||||
{
|
||||
Author = lqDecision.Item.Author,
|
||||
Book = lqDecision.Item.Book,
|
||||
Edition = lqDecision.Item.Edition,
|
||||
Path = @"C:\Test\Music\Alien Ant Farm\Alien Ant Farm - 01 - Pilot.mp3".AsOsAgnostic(),
|
||||
Quality = new QualityModel(Quality.AZW3),
|
||||
Size = 1.Megabytes(),
|
||||
FileTrackInfo = new ParsedTrackInfo
|
||||
{
|
||||
ReleaseGroup = "DRONE"
|
||||
}
|
||||
});
|
||||
|
||||
var all = new List<ImportDecision<LocalBook>>();
|
||||
all.Add(lqDecision);
|
||||
all.Add(hqDecision);
|
||||
|
||||
var results = Subject.Import(all, false);
|
||||
|
||||
results.Should().HaveCount(all.Count);
|
||||
results.Should().ContainSingle(d => d.Result == ImportResultType.Imported);
|
||||
results.Should().ContainSingle(d => d.Result == ImportResultType.Imported && d.ImportDecision.Item.Size == hqDecision.Item.Size);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_import_larger_files_for_same_quality_first()
|
||||
{
|
||||
var fileDecision = _approvedDecisions.First();
|
||||
fileDecision.Item.Size = 1.Gigabytes();
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ public List<ImportResult> Import(List<ImportDecision<LocalBook>> decisions, bool
|
|||
var filesToAdd = new List<BookFile>(qualifiedImports.Count);
|
||||
var trackImportedEvents = new List<TrackImportedEvent>(qualifiedImports.Count);
|
||||
|
||||
foreach (var importDecision in qualifiedImports.OrderByDescending(e => e.Item.Size))
|
||||
foreach (var importDecision in qualifiedImports)
|
||||
{
|
||||
var localTrack = importDecision.Item;
|
||||
var oldFiles = new List<BookFile>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue