mirror of
https://github.com/Readarr/Readarr
synced 2025-12-28 11:13:22 +01:00
Fixed: Don't write audio tags if there are no updates
(cherry picked from commit 1e147580729e24fbb6d8707d2a0ddfc8bd036d43)
This commit is contained in:
parent
3dc86b3a01
commit
fab7558bd4
2 changed files with 39 additions and 7 deletions
|
|
@ -5,12 +5,15 @@
|
|||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Books;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
|
@ -166,7 +169,7 @@ private void VerifySame(AudioTag a, AudioTag b, string[] skipProperties)
|
|||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
||||
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||
public void should_read_duration(string filename, string[] ignored)
|
||||
{
|
||||
var path = Path.Combine(_testdir, filename);
|
||||
|
|
@ -177,7 +180,7 @@ public void should_read_duration(string filename, string[] ignored)
|
|||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
||||
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||
public void should_read_write_tags(string filename, string[] skipProperties)
|
||||
{
|
||||
GivenFileCopy(filename);
|
||||
|
|
@ -198,7 +201,7 @@ public void should_read_write_tags(string filename, string[] skipProperties)
|
|||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
||||
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||
public void should_read_audiotag_from_file_with_no_tags(string filename, string[] skipProperties)
|
||||
{
|
||||
GivenFileCopy(filename);
|
||||
|
|
@ -220,7 +223,7 @@ public void should_read_audiotag_from_file_with_no_tags(string filename, string[
|
|||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
||||
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||
public void should_read_parsedtrackinfo_from_file_with_no_tags(string filename, string[] skipProperties)
|
||||
{
|
||||
GivenFileCopy(filename);
|
||||
|
|
@ -235,7 +238,7 @@ public void should_read_parsedtrackinfo_from_file_with_no_tags(string filename,
|
|||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
||||
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||
public void should_set_quality_and_mediainfo_for_corrupt_file(string filename, string[] skipProperties)
|
||||
{
|
||||
// use missing to simulate corrupt
|
||||
|
|
@ -250,7 +253,7 @@ public void should_set_quality_and_mediainfo_for_corrupt_file(string filename, s
|
|||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
||||
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||
public void should_read_file_with_only_title_tag(string filename, string[] ignored)
|
||||
{
|
||||
GivenFileCopy(filename);
|
||||
|
|
@ -270,7 +273,7 @@ public void should_read_file_with_only_title_tag(string filename, string[] ignor
|
|||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
||||
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||
public void should_remove_date_from_tags_when_not_in_metadata(string filename, string[] ignored)
|
||||
{
|
||||
GivenFileCopy(filename);
|
||||
|
|
@ -365,6 +368,29 @@ public void write_tags_should_update_trackfile_size_and_modified(string filename
|
|||
var fileInfo = _diskProvider.GetFileInfo(file.Path);
|
||||
file.Modified.Should().Be(fileInfo.LastWriteTimeUtc);
|
||||
file.Size.Should().Be(fileInfo.Length);
|
||||
|
||||
Mocker.GetMock<IEventAggregator>()
|
||||
.Verify(v => v.PublishEvent(It.IsAny<BookFileRetaggedEvent>()), Times.Once());
|
||||
}
|
||||
|
||||
[TestCase("nin.mp3")]
|
||||
public void write_tags_should_not_update_tags_if_already_updated(string filename)
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.Setup(x => x.ScrubAudioTags)
|
||||
.Returns(true);
|
||||
|
||||
GivenFileCopy(filename);
|
||||
|
||||
var file = GivenPopulatedTrackfile(0);
|
||||
|
||||
file.Path = _copiedFile;
|
||||
Subject.WriteTags(file, false, true);
|
||||
Subject.WriteTags(file, false, true);
|
||||
Subject.WriteTags(file, false, true);
|
||||
|
||||
Mocker.GetMock<IEventAggregator>()
|
||||
.Verify(v => v.PublishEvent(It.IsAny<BookFileRetaggedEvent>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
|||
|
|
@ -174,6 +174,12 @@ public void WriteTags(BookFile trackfile, bool newDownload, bool force = false)
|
|||
|
||||
var diff = ReadAudioTag(path).Diff(newTags);
|
||||
|
||||
if (!diff.Any())
|
||||
{
|
||||
_logger.Debug("No tags update for {0} due to no difference", trackfile);
|
||||
return;
|
||||
}
|
||||
|
||||
_rootFolderWatchingService.ReportFileSystemChangeBeginning(path);
|
||||
|
||||
if (_configService.ScrubAudioTags)
|
||||
|
|
|
|||
Loading…
Reference in a new issue