From a4f63e728caf60ddd485160119b5ed7dad8eba66 Mon Sep 17 00:00:00 2001
From: Mark McDowall <mark@mcdowall.ca>
Date: Sun, 7 Oct 2018 18:27:32 -0700
Subject: [PATCH] Fixed: Don't use media info for non-video files

Fixes #2745
---
 .../EpisodeImport/ImportDecisionMakerFixture.cs      | 10 +++++-----
 .../Extras/Metadata/ExistingMetadataImporter.cs      |  8 ++++----
 .../Extras/Others/ExistingOtherExtraImporter.cs      |  8 ++++----
 .../Extras/Subtitles/ExistingSubtitleImporter.cs     |  8 ++++----
 .../EpisodeImport/Aggregation/AggregationService.cs  | 12 +++++++-----
 .../MediaFiles/EpisodeImport/ImportDecisionMaker.cs  |  8 ++++----
 .../EpisodeImport/Manual/ManualImportService.cs      |  8 ++++----
 src/NzbDrone.sln.DotSettings                         |  9 +++++++++
 8 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs
index 416311940..719682080 100644
--- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs
+++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs
@@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
 
         private void GivenAugmentationSuccess()
         {
-            Mocker.GetMock<IAugmentingService>()
+            Mocker.GetMock<IAggregationService>()
                   .Setup(s => s.Augment(It.IsAny<LocalEpisode>(), It.IsAny<bool>()))
                   .Callback<LocalEpisode, bool>((localEpisode, otherFiles) =>
                   {
@@ -158,7 +158,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
         {
             GivenSpecifications(_pass1);
 
-            Mocker.GetMock<IAugmentingService>()
+            Mocker.GetMock<IAggregationService>()
                   .Setup(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<bool>()))
                   .Throws<TestException>();
 
@@ -173,7 +173,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
 
             Subject.GetImportDecisions(_videoFiles, _series);
 
-            Mocker.GetMock<IAugmentingService>()
+            Mocker.GetMock<IAggregationService>()
                   .Verify(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<bool>()), Times.Exactly(_videoFiles.Count));
 
             ExceptionVerification.ExpectedErrors(3);
@@ -195,7 +195,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
 
             var decisions = Subject.GetImportDecisions(_videoFiles, _series);
 
-            Mocker.GetMock<IAugmentingService>()
+            Mocker.GetMock<IAggregationService>()
                   .Verify(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<bool>()), Times.Exactly(_videoFiles.Count));
 
             decisions.Should().HaveCount(3);
@@ -205,7 +205,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
         [Test]
         public void should_return_a_decision_when_exception_is_caught()
         {
-            Mocker.GetMock<IAugmentingService>()
+            Mocker.GetMock<IAggregationService>()
                   .Setup(c => c.Augment(It.IsAny<LocalEpisode>(), It.IsAny<bool>()))
                   .Throws<TestException>();
 
diff --git a/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs b/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs
index b5250f6e6..e43949142 100644
--- a/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs
+++ b/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs
@@ -16,18 +16,18 @@ namespace NzbDrone.Core.Extras.Metadata
     public class ExistingMetadataImporter : ImportExistingExtraFilesBase<MetadataFile>
     {
         private readonly IExtraFileService<MetadataFile> _metadataFileService;
-        private readonly IAugmentingService _augmentingService;
+        private readonly IAggregationService _aggregationService;
         private readonly Logger _logger;
         private readonly List<IMetadata> _consumers;
 
         public ExistingMetadataImporter(IExtraFileService<MetadataFile> metadataFileService,
                                         IEnumerable<IMetadata> consumers,
-                                        IAugmentingService augmentingService,
+                                        IAggregationService aggregationService,
                                         Logger logger)
         : base(metadataFileService)
         {
             _metadataFileService = metadataFileService;
-            _augmentingService = augmentingService;
+            _aggregationService = aggregationService;
             _logger = logger;
             _consumers = consumers.ToList();
         }
@@ -71,7 +71,7 @@ namespace NzbDrone.Core.Extras.Metadata
 
                         try
                         {
-                            _augmentingService.Augment(localEpisode, false);
+                            _aggregationService.Augment(localEpisode, false);
                         }
                         catch (AugmentingFailedException ex)
                         {
diff --git a/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs b/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs
index 724f4968c..23e422eda 100644
--- a/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs
+++ b/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs
@@ -15,16 +15,16 @@ namespace NzbDrone.Core.Extras.Others
     public class ExistingOtherExtraImporter : ImportExistingExtraFilesBase<OtherExtraFile>
     {
         private readonly IExtraFileService<OtherExtraFile> _otherExtraFileService;
-        private readonly IAugmentingService _augmentingService;
+        private readonly IAggregationService _aggregationService;
         private readonly Logger _logger;
 
         public ExistingOtherExtraImporter(IExtraFileService<OtherExtraFile> otherExtraFileService,
-                                          IAugmentingService augmentingService,
+                                          IAggregationService aggregationService,
                                           Logger logger)
             : base(otherExtraFileService)
         {
             _otherExtraFileService = otherExtraFileService;
-            _augmentingService = augmentingService;
+            _aggregationService = aggregationService;
             _logger = logger;
         }
 
@@ -56,7 +56,7 @@ namespace NzbDrone.Core.Extras.Others
 
                 try
                 {
-                    _augmentingService.Augment(localEpisode, false);
+                    _aggregationService.Augment(localEpisode, false);
                 }
                 catch (AugmentingFailedException ex)
                 {
diff --git a/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs b/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs
index c15732351..79c4544b1 100644
--- a/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs
+++ b/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs
@@ -14,16 +14,16 @@ namespace NzbDrone.Core.Extras.Subtitles
     public class ExistingSubtitleImporter : ImportExistingExtraFilesBase<SubtitleFile>
     {
         private readonly IExtraFileService<SubtitleFile> _subtitleFileService;
-        private readonly IAugmentingService _augmentingService;
+        private readonly IAggregationService _aggregationService;
         private readonly Logger _logger;
 
         public ExistingSubtitleImporter(IExtraFileService<SubtitleFile> subtitleFileService,
-                                        IAugmentingService augmentingService,
+                                        IAggregationService aggregationService,
                                         Logger logger)
             : base (subtitleFileService)
         {
             _subtitleFileService = subtitleFileService;
-            _augmentingService = augmentingService;
+            _aggregationService = aggregationService;
             _logger = logger;
         }
 
@@ -51,7 +51,7 @@ namespace NzbDrone.Core.Extras.Subtitles
 
                     try
                     {
-                        _augmentingService.Augment(localEpisode, false);
+                        _aggregationService.Augment(localEpisode, false);
                     }
                     catch (AugmentingFailedException ex)
                     {
diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/AggregationService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/AggregationService.cs
index b66078ce6..14ff63a98 100644
--- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/AggregationService.cs
+++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/AggregationService.cs
@@ -10,12 +10,12 @@ using NzbDrone.Core.Parser.Model;
 
 namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation
 {
-    public interface IAugmentingService
+    public interface IAggregationService
     {
         LocalEpisode Augment(LocalEpisode localEpisode, bool otherFiles);
     }
 
-    public class AugmentingService : IAugmentingService
+    public class AggregationService : IAggregationService
     {
         private readonly IEnumerable<IAggregateLocalEpisode> _augmenters;
         private readonly IDiskProvider _diskProvider;
@@ -23,7 +23,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation
         private readonly IConfigService _configService;
         private readonly Logger _logger;
 
-        public AugmentingService(IEnumerable<IAggregateLocalEpisode> augmenters,
+        public AggregationService(IEnumerable<IAggregateLocalEpisode> augmenters,
                                  IDiskProvider diskProvider,
                                  IVideoFileInfoReader videoFileInfoReader,
                                  IConfigService configService,
@@ -38,11 +38,13 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation
 
         public LocalEpisode Augment(LocalEpisode localEpisode, bool otherFiles)
         {
+            var isMediaFile = MediaFileExtensions.Extensions.Contains(Path.GetExtension(localEpisode.Path));
+
             if (localEpisode.DownloadClientEpisodeInfo == null &&
                 localEpisode.FolderEpisodeInfo == null &&
                 localEpisode.FileEpisodeInfo == null)
             {
-                if (MediaFileExtensions.Extensions.Contains(Path.GetExtension(localEpisode.Path)))
+                if (isMediaFile)
                 {
                     throw new AugmentingFailedException("Unable to parse episode info from path: {0}", localEpisode.Path);
                 }
@@ -50,7 +52,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation
 
             localEpisode.Size = _diskProvider.GetFileSize(localEpisode.Path);
 
-            if (!localEpisode.ExistingFile || _configService.EnableMediaInfo)
+            if (isMediaFile && (!localEpisode.ExistingFile || _configService.EnableMediaInfo))
             {
                 localEpisode.MediaInfo = _videoFileInfoReader.GetMediaInfo(localEpisode.Path);
             }
diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs
index 28180f404..8507bd3c4 100644
--- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs
+++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs
@@ -23,21 +23,21 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
     {
         private readonly IEnumerable<IImportDecisionEngineSpecification> _specifications;
         private readonly IMediaFileService _mediaFileService;
-        private readonly IAugmentingService _augmentingService;
+        private readonly IAggregationService _aggregationService;
         private readonly IDiskProvider _diskProvider;
         private readonly IDetectSample _detectSample;
         private readonly Logger _logger;
 
         public ImportDecisionMaker(IEnumerable<IImportDecisionEngineSpecification> specifications,
                                    IMediaFileService mediaFileService,
-                                   IAugmentingService augmentingService,
+                                   IAggregationService aggregationService,
                                    IDiskProvider diskProvider,
                                    IDetectSample detectSample,
                                    Logger logger)
         {
             _specifications = specifications;
             _mediaFileService = mediaFileService;
-            _augmentingService = augmentingService;
+            _aggregationService = aggregationService;
             _diskProvider = diskProvider;
             _detectSample = detectSample;
             _logger = logger;
@@ -96,7 +96,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
 
             try
             {
-                _augmentingService.Augment(localEpisode, otherFiles);
+                _aggregationService.Augment(localEpisode, otherFiles);
 
                 if (localEpisode.Episodes.Empty())
                 {
diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs
index 40ae716fe..b3110a540 100644
--- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs
+++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs
@@ -34,7 +34,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
         private readonly IEpisodeService _episodeService;
         private readonly IVideoFileInfoReader _videoFileInfoReader;
         private readonly IImportApprovedEpisodes _importApprovedEpisodes;
-        private readonly IAugmentingService _augmentingService;
+        private readonly IAggregationService _aggregationService;
         private readonly ITrackedDownloadService _trackedDownloadService;
         private readonly IDownloadedEpisodesImportService _downloadedEpisodesImportService;
         private readonly IEventAggregator _eventAggregator;
@@ -47,7 +47,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
                                    ISeriesService seriesService,
                                    IEpisodeService episodeService,
                                    IVideoFileInfoReader videoFileInfoReader,
-                                   IAugmentingService augmentingService,
+                                   IAggregationService aggregationService,
                                    IImportApprovedEpisodes importApprovedEpisodes,
                                    ITrackedDownloadService trackedDownloadService,
                                    IDownloadedEpisodesImportService downloadedEpisodesImportService,
@@ -61,7 +61,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
             _seriesService = seriesService;
             _episodeService = episodeService;
             _videoFileInfoReader = videoFileInfoReader;
-            _augmentingService = augmentingService;
+            _aggregationService = aggregationService;
             _importApprovedEpisodes = importApprovedEpisodes;
             _trackedDownloadService = trackedDownloadService;
             _downloadedEpisodesImportService = downloadedEpisodesImportService;
@@ -281,7 +281,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
                     localEpisode.FolderEpisodeInfo = Parser.Parser.ParseTitle(file.FolderName);
                 }
 
-                localEpisode = _augmentingService.Augment(localEpisode, false);
+                localEpisode = _aggregationService.Augment(localEpisode, false);
 
                 // Apply the user-chosen values.
                 localEpisode.Series = series;
diff --git a/src/NzbDrone.sln.DotSettings b/src/NzbDrone.sln.DotSettings
index 1d351d0ce..275ac5005 100644
--- a/src/NzbDrone.sln.DotSettings
+++ b/src/NzbDrone.sln.DotSettings
@@ -30,9 +30,13 @@
 	<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_WHILE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
 	<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_FIXED_STMT/@EntryValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_USINGS_STMT/@EntryValue">True</s:Boolean>
+	<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
+	<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSORHOLDER_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
 	<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
+	<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
 	<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
 	<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
+	<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_EMBEDDED_STATEMENT_ON_SAME_LINE/@EntryValue">ALWAYS</s:String>
 	<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">ON_SINGLE_LINE</s:String>
 	<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AllowAlias/@EntryValue">False</s:Boolean>
 	<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/CanUseGlobalAlias/@EntryValue">False</s:Boolean>
@@ -71,7 +75,12 @@
 	<s:Boolean x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File_003A_003AC_003A_005CDropbox_005CGit_005CNzbDrone_005CNzbDrone_002Esln_002EDotSettings/@KeyIndexDefined">True</s:Boolean>
 	<s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File_003A_003AC_003A_005CDropbox_005CGit_005CNzbDrone_005CNzbDrone_002Esln_002EDotSettings/RelativePriority/@EntryValue">2</s:Double>
 	<s:Boolean x:Key="/Default/Environment/MemoryUsageIndicator/IsVisible/@EntryValue">False</s:Boolean>
+	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/TextControl/HighlightCurrentLine/@EntryValue">True</s:Boolean>