mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-31 04:00:18 -07:00
Fixed: Errors logged during import when existing episode file is partial removed in the DB
Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
fc2c5b7521
commit
855a8dbf85
4 changed files with 36 additions and 0 deletions
|
@ -224,5 +224,18 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
|
|||
|
||||
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_track_file_is_null()
|
||||
{
|
||||
_localTrack.Tracks = Builder<Track>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.TrackFileId = 1)
|
||||
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(null))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,5 +181,20 @@ namespace NzbDrone.Core.Test.MediaFiles
|
|||
|
||||
Subject.UpgradeTrackFile(_trackFile, _localTrack).OldFiles.Count.Should().Be(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_import_if_existing_file_doesnt_exist_in_db()
|
||||
{
|
||||
_localTrack.Tracks = Builder<Track>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(e => e.TrackFileId = 1)
|
||||
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(null))
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.UpgradeTrackFile(_trackFile, _localTrack);
|
||||
|
||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(_localTrack.Tracks.Single().TrackFile.Value, It.IsAny<DeleteMediaFileReason>()), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,13 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
|
|||
foreach (var track in localTrack.Tracks.Where(e => e.TrackFileId > 0))
|
||||
{
|
||||
var trackFile = track.TrackFile.Value;
|
||||
|
||||
if (trackFile == null)
|
||||
{
|
||||
_logger.Trace("Unable to get track file details from the DB. TrackId: {0} TrackFileId: {1}", track.Id, track.TrackFileId);
|
||||
continue;
|
||||
}
|
||||
|
||||
var qualityCompare = qualityComparer.Compare(localTrack.Quality.Quality, trackFile.Quality.Quality);
|
||||
|
||||
if (qualityCompare < 0)
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
var existingFiles = localTrack.Tracks
|
||||
.Where(e => e.TrackFileId > 0)
|
||||
.Select(e => e.TrackFile.Value)
|
||||
.Where(e => e != null)
|
||||
.GroupBy(e => e.Id)
|
||||
.ToList();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue