diff --git a/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs b/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs
new file mode 100644
index 000000000..7a2c50e71
--- /dev/null
+++ b/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs
@@ -0,0 +1,14 @@
+using FluentMigrator;
+using NzbDrone.Core.Datastore.Migration.Framework;
+
+namespace NzbDrone.Core.Datastore.Migration
+{
+ [Migration(16)]
+ public class updated_imported_history_item : NzbDroneMigrationBase
+ {
+ protected override void MainDbUpgrade()
+ {
+ Execute.Sql(@"UPDATE HISTORY SET Data = replace( Data, '""Path""', '""ImportedPath""' ) WHERE EventType=3");
+ }
+ }
+}
diff --git a/NzbDrone.Core/History/HistoryService.cs b/NzbDrone.Core/History/HistoryService.cs
index 40f637fcf..349d81c08 100644
--- a/NzbDrone.Core/History/HistoryService.cs
+++ b/NzbDrone.Core/History/HistoryService.cs
@@ -62,7 +62,7 @@ namespace NzbDrone.Core.History
{
var history = new History
{
- EventType = HistoryEventType.Grabbed,
+ EventType = HistoryEventType.Grabbed,
Date = DateTime.UtcNow,
Quality = message.Episode.ParsedEpisodeInfo.Quality,
SourceTitle = message.Episode.Report.Title,
@@ -81,20 +81,21 @@ namespace NzbDrone.Core.History
public void Handle(EpisodeImportedEvent message)
{
- foreach (var episode in message.EpisodeFile.Episodes.Value)
+ foreach (var episode in message.DroppedEpisode.Episodes)
{
var history = new History
{
EventType = HistoryEventType.DownloadFolderImported,
Date = DateTime.UtcNow,
- Quality = message.EpisodeFile.Quality,
- SourceTitle = message.EpisodeFile.Path,
- SeriesId = message.EpisodeFile.SeriesId,
+ Quality = message.DroppedEpisode.Quality,
+ SourceTitle = message.ImportedEpisode.SceneName,
+ SeriesId = message.ImportedEpisode.SeriesId,
EpisodeId = episode.Id
};
- history.Data.Add("Path", message.EpisodeFile.Path);
- history.Data.Add("Filename", Path.GetFileNameWithoutExtension(message.EpisodeFile.Path));
+ history.Data.Add("FileId", message.ImportedEpisode.Id.ToString());
+ history.Data.Add("DroppedPath", message.DroppedEpisode.Path);
+ history.Data.Add("ImportedPath", message.ImportedEpisode.Path);
_historyRepository.Insert(history);
}
diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs
index 0757b1495..539bb8ccd 100644
--- a/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs
+++ b/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs
@@ -65,12 +65,14 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
episodeFile.SceneName = Path.GetFileNameWithoutExtension(localEpisode.Path.CleanFilePath());
episodeFile.Episodes = localEpisode.Episodes;
+
if (newDownload)
{
episodeFile = _episodeFileUpgrader.UpgradeEpisodeFile(episodeFile, localEpisode);
- _messageAggregator.PublishEvent(new EpisodeImportedEvent(episodeFile));
+ _messageAggregator.PublishEvent(new EpisodeImportedEvent(localEpisode, episodeFile));
}
-
+
+
_mediaFileService.Add(episodeFile);
imported.Add(importDecision);
}
diff --git a/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs b/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs
index 9c8e59cdc..2f166b069 100644
--- a/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs
+++ b/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs
@@ -1,14 +1,17 @@
using NzbDrone.Common.Messaging;
+using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.Events
{
public class EpisodeImportedEvent : IEvent
{
- public EpisodeFile EpisodeFile { get; private set; }
+ public LocalEpisode DroppedEpisode { get; private set; }
+ public EpisodeFile ImportedEpisode { get; private set; }
- public EpisodeImportedEvent(EpisodeFile episodeFile)
+ public EpisodeImportedEvent(LocalEpisode droppedEpisode, EpisodeFile importedEpisode)
{
- EpisodeFile = episodeFile;
+ DroppedEpisode = droppedEpisode;
+ ImportedEpisode = importedEpisode;
}
}
}
\ No newline at end of file
diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj
index 9ed55a6ff..26f5df9b8 100644
--- a/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/NzbDrone.Core/NzbDrone.Core.csproj
@@ -158,6 +158,7 @@