mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-22 14:33:30 -07:00
Fixed: Don't write audio tags if there are no updates
This commit is contained in:
parent
98245a0ed8
commit
5d7452af1c
2 changed files with 40 additions and 8 deletions
|
@ -5,11 +5,14 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.MediaFiles.Events;
|
||||||
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
@ -166,7 +169,7 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||||
public void should_read_duration(string filename, string[] ignored)
|
public void should_read_duration(string filename, string[] ignored)
|
||||||
{
|
{
|
||||||
var path = Path.Combine(_testdir, filename);
|
var path = Path.Combine(_testdir, filename);
|
||||||
|
@ -177,7 +180,7 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||||
public void should_read_write_tags(string filename, string[] skipProperties)
|
public void should_read_write_tags(string filename, string[] skipProperties)
|
||||||
{
|
{
|
||||||
GivenFileCopy(filename);
|
GivenFileCopy(filename);
|
||||||
|
@ -195,7 +198,7 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||||
public void should_remove_mb_tags(string filename, string[] skipProperties)
|
public void should_remove_mb_tags(string filename, string[] skipProperties)
|
||||||
{
|
{
|
||||||
GivenFileCopy(filename);
|
GivenFileCopy(filename);
|
||||||
|
@ -229,7 +232,7 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[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)
|
public void should_read_audiotag_from_file_with_no_tags(string filename, string[] skipProperties)
|
||||||
{
|
{
|
||||||
GivenFileCopy(filename);
|
GivenFileCopy(filename);
|
||||||
|
@ -251,7 +254,7 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[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)
|
public void should_read_parsedtrackinfo_from_file_with_no_tags(string filename, string[] skipProperties)
|
||||||
{
|
{
|
||||||
GivenFileCopy(filename);
|
GivenFileCopy(filename);
|
||||||
|
@ -266,7 +269,7 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[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)
|
public void should_set_quality_and_mediainfo_for_corrupt_file(string filename, string[] skipProperties)
|
||||||
{
|
{
|
||||||
// use missing to simulate corrupt
|
// use missing to simulate corrupt
|
||||||
|
@ -281,7 +284,7 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[TestCaseSource(typeof(TestCaseFactory), "TestCases")]
|
[TestCaseSource(typeof(TestCaseFactory), nameof(TestCaseFactory.TestCases))]
|
||||||
public void should_read_file_with_only_title_tag(string filename, string[] ignored)
|
public void should_read_file_with_only_title_tag(string filename, string[] ignored)
|
||||||
{
|
{
|
||||||
GivenFileCopy(filename);
|
GivenFileCopy(filename);
|
||||||
|
@ -301,7 +304,7 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[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)
|
public void should_remove_date_from_tags_when_not_in_metadata(string filename, string[] ignored)
|
||||||
{
|
{
|
||||||
GivenFileCopy(filename);
|
GivenFileCopy(filename);
|
||||||
|
@ -413,6 +416,29 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
|
||||||
var fileInfo = _diskProvider.GetFileInfo(file.Path);
|
var fileInfo = _diskProvider.GetFileInfo(file.Path);
|
||||||
file.Modified.Should().Be(fileInfo.LastWriteTimeUtc);
|
file.Modified.Should().Be(fileInfo.LastWriteTimeUtc);
|
||||||
file.Size.Should().Be(fileInfo.Length);
|
file.Size.Should().Be(fileInfo.Length);
|
||||||
|
|
||||||
|
Mocker.GetMock<IEventAggregator>()
|
||||||
|
.Verify(v => v.PublishEvent(It.IsAny<TrackFileRetaggedEvent>()), 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<TrackFileRetaggedEvent>()), Times.Once());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,6 +220,12 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
|
|
||||||
var diff = oldTags.Diff(newTags);
|
var diff = oldTags.Diff(newTags);
|
||||||
|
|
||||||
|
if (!diff.Any())
|
||||||
|
{
|
||||||
|
_logger.Debug("No tags update for {0} due to no difference", trackfile);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_rootFolderWatchingService.ReportFileSystemChangeBeginning(path);
|
_rootFolderWatchingService.ReportFileSystemChangeBeginning(path);
|
||||||
|
|
||||||
if (_configService.ScrubAudioTags)
|
if (_configService.ScrubAudioTags)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue