diff --git a/src/NzbDrone.Core/History/History.cs b/src/NzbDrone.Core/History/History.cs index be35637c8..e6c2fe223 100644 --- a/src/NzbDrone.Core/History/History.cs +++ b/src/NzbDrone.Core/History/History.cs @@ -36,6 +36,7 @@ namespace NzbDrone.Core.History SeriesFolderImported = 2, DownloadFolderImported = 3, DownloadFailed = 4, - EpisodeFileDeleted = 5 + EpisodeFileDeleted = 5, + EpisodeFileRenamed = 6 } } \ No newline at end of file diff --git a/src/NzbDrone.Core/History/HistoryService.cs b/src/NzbDrone.Core/History/HistoryService.cs index 32815beef..38450727a 100644 --- a/src/NzbDrone.Core/History/HistoryService.cs +++ b/src/NzbDrone.Core/History/HistoryService.cs @@ -32,6 +32,7 @@ namespace NzbDrone.Core.History IHandle, IHandle, IHandle, + IHandle, IHandle { private readonly IHistoryRepository _historyRepository; @@ -257,6 +258,34 @@ namespace NzbDrone.Core.History } } + public void Handle(EpisodeFileRenamedEvent message) + { + var sourcePath = message.OriginalPath; + var sourceRelativePath = message.Series.Path.GetRelativePath(message.OriginalPath); + var path = Path.Combine(message.Series.Path, message.EpisodeFile.RelativePath); + var relativePath = message.EpisodeFile.RelativePath; + + foreach (var episode in message.EpisodeFile.Episodes.Value) + { + var history = new History + { + EventType = HistoryEventType.EpisodeFileRenamed, + Date = DateTime.UtcNow, + Quality = message.EpisodeFile.Quality, + SourceTitle = message.OriginalPath, + SeriesId = message.EpisodeFile.SeriesId, + EpisodeId = episode.Id, + }; + + history.Data.Add("SourcePath", sourcePath); + history.Data.Add("SourceRelativePath", sourceRelativePath); + history.Data.Add("Path", path); + history.Data.Add("RelativePath", relativePath); + + _historyRepository.Insert(history); + } + } + public void Handle(SeriesDeletedEvent message) { _historyRepository.DeleteForSeries(message.Series.Id); diff --git a/src/NzbDrone.Core/MediaFiles/Events/EpisodeFileRenamedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/EpisodeFileRenamedEvent.cs new file mode 100644 index 000000000..98708ce5e --- /dev/null +++ b/src/NzbDrone.Core/MediaFiles/Events/EpisodeFileRenamedEvent.cs @@ -0,0 +1,19 @@ +using NzbDrone.Common.Messaging; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.MediaFiles.Events +{ + public class EpisodeFileRenamedEvent : IEvent + { + public Series Series { get; private set; } + public EpisodeFile EpisodeFile { get; private set; } + public string OriginalPath { get; private set; } + + public EpisodeFileRenamedEvent(Series series, EpisodeFile episodeFile, string originalPath) + { + Series = series; + EpisodeFile = episodeFile; + OriginalPath = originalPath; + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs b/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs index 4cfe84b37..e98598d43 100644 --- a/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs @@ -125,6 +125,8 @@ namespace NzbDrone.Core.MediaFiles renamed.Add(episodeFile); _logger.Debug("Renamed episode file: {0}", episodeFile); + + _eventAggregator.PublishEvent(new EpisodeFileRenamedEvent(series, episodeFile, episodeFilePath)); } catch (SameFilenameException ex) { diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 70d3b0ab6..8753e91f7 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -787,6 +787,7 @@ + diff --git a/src/UI/Activity/History/Details/HistoryDetailsLayoutTemplate.hbs b/src/UI/Activity/History/Details/HistoryDetailsLayoutTemplate.hbs index 892dbfc35..ec1181c90 100644 --- a/src/UI/Activity/History/Details/HistoryDetailsLayoutTemplate.hbs +++ b/src/UI/Activity/History/Details/HistoryDetailsLayoutTemplate.hbs @@ -8,6 +8,7 @@ {{#if_eq eventType compare="downloadFailed"}}Download Failed{{/if_eq}} {{#if_eq eventType compare="downloadFolderImported"}}Episode Imported{{/if_eq}} {{#if_eq eventType compare="episodeFileDeleted"}}Episode File Deleted{{/if_eq}} + {{#if_eq eventType compare="episodeFileRenamed"}}Episode File Renamed{{/if_eq}} diff --git a/src/UI/Activity/History/Details/HistoryDetailsViewTemplate.hbs b/src/UI/Activity/History/Details/HistoryDetailsViewTemplate.hbs index 89a757660..b70b8e4cb 100644 --- a/src/UI/Activity/History/Details/HistoryDetailsViewTemplate.hbs +++ b/src/UI/Activity/History/Details/HistoryDetailsViewTemplate.hbs @@ -100,4 +100,23 @@ {{/with}} -{{/if_eq}} \ No newline at end of file +{{/if_eq}} + +{{#if_eq eventType compare="episodeFileRenamed"}} +
+ +
Source Path:
+
{{sourceTitle}}
+ + {{#with data}} +
Source Relative Path:
+
{{sourceRelativePath}}
+ +
Path:
+
{{path}}
+ +
Relative Path:
+
{{relativePath}}
+ {{/with}} +
+{{/if_eq}} diff --git a/src/UI/Activity/History/HistoryCollection.js b/src/UI/Activity/History/HistoryCollection.js index 3bd564309..661e2221a 100644 --- a/src/UI/Activity/History/HistoryCollection.js +++ b/src/UI/Activity/History/HistoryCollection.js @@ -46,6 +46,10 @@ var Collection = PageableCollection.extend({ 'deleted' : [ 'eventType', '5' + ], + 'renamed' : [ + 'eventType', + '6' ] }, @@ -80,4 +84,4 @@ Collection = AsFilteredCollection.call(Collection); Collection = AsSortedCollection.call(Collection); Collection = AsPersistedStateCollection.call(Collection); -module.exports = Collection; \ No newline at end of file +module.exports = Collection; diff --git a/src/UI/Activity/History/HistoryLayout.js b/src/UI/Activity/History/HistoryLayout.js index ae7e4c93e..29d6f44af 100644 --- a/src/UI/Activity/History/HistoryLayout.js +++ b/src/UI/Activity/History/HistoryLayout.js @@ -129,6 +129,13 @@ module.exports = Marionette.Layout.extend({ tooltip : 'Deleted', icon : 'icon-sonarr-deleted', callback : this._setFilter + }, + { + key : 'renamed', + title : '', + tooltip : 'Renamed', + icon : 'icon-sonarr-rename', + callback : this._setFilter } ] }; diff --git a/src/UI/Cells/EventTypeCell.js b/src/UI/Cells/EventTypeCell.js index 4ca9a85ae..1b374d67f 100644 --- a/src/UI/Cells/EventTypeCell.js +++ b/src/UI/Cells/EventTypeCell.js @@ -31,6 +31,10 @@ module.exports = NzbDroneCell.extend({ icon = 'icon-sonarr-deleted'; toolTip = 'Episode file deleted'; break; + case 'episodeFileRenamed': + icon = 'icon-sonarr-rename'; + toolTip = 'Episode file renamed'; + break; default: icon = 'icon-sonarr-unknown'; toolTip = 'unknown event'; @@ -41,4 +45,4 @@ module.exports = NzbDroneCell.extend({ return this; } -}); \ No newline at end of file +}); diff --git a/src/UI/Content/icons.less b/src/UI/Content/icons.less index 6736cb70f..3f41edb40 100644 --- a/src/UI/Content/icons.less +++ b/src/UI/Content/icons.less @@ -507,4 +507,4 @@ .icon-sonarr-header-rejections { .fa-icon-content(@fa-var-exclamation-circle); -} \ No newline at end of file +}