New: Store episode renames in History

Closes #1541
pull/2070/head
Mark McDowall 8 years ago committed by Mark McDowall
parent f293b9a44e
commit 9312f0a462

@ -36,6 +36,7 @@ namespace NzbDrone.Core.History
SeriesFolderImported = 2,
DownloadFolderImported = 3,
DownloadFailed = 4,
EpisodeFileDeleted = 5
EpisodeFileDeleted = 5,
EpisodeFileRenamed = 6
}
}

@ -32,6 +32,7 @@ namespace NzbDrone.Core.History
IHandle<EpisodeImportedEvent>,
IHandle<DownloadFailedEvent>,
IHandle<EpisodeFileDeletedEvent>,
IHandle<EpisodeFileRenamedEvent>,
IHandle<SeriesDeletedEvent>
{
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);

@ -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;
}
}
}

@ -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)
{

@ -787,6 +787,7 @@
<Compile Include="MediaFiles\EpisodeImport\Specifications\UnverifiedSceneNumberingSpecification.cs" />
<Compile Include="MediaFiles\EpisodeImport\Specifications\UpgradeSpecification.cs" />
<Compile Include="MediaFiles\Events\EpisodeFileAddedEvent.cs" />
<Compile Include="MediaFiles\Events\EpisodeFileRenamedEvent.cs" />
<Compile Include="MediaFiles\Events\EpisodeFileDeletedEvent.cs" />
<Compile Include="MediaFiles\Events\EpisodeFolderCreatedEvent.cs" />
<Compile Include="MediaFiles\Events\EpisodeImportedEvent.cs" />

@ -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}}
</h3>
</div>

@ -100,4 +100,23 @@
</dd>
{{/with}}
</dl>
{{/if_eq}}
{{/if_eq}}
{{#if_eq eventType compare="episodeFileRenamed"}}
<dl class="dl-horizontal">
<dt>Source Path:</dt>
<dd>{{sourceTitle}}</dd>
{{#with data}}
<dt>Source Relative Path:</dt>
<dd>{{sourceRelativePath}}</dd>
<dt>Path:</dt>
<dd>{{path}}</dd>
<dt>Relative Path:</dt>
<dd>{{relativePath}}</dd>
{{/with}}
</dl>
{{/if_eq}}

@ -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;
module.exports = Collection;

@ -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
}
]
};

@ -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;
}
});
});

@ -507,4 +507,4 @@
.icon-sonarr-header-rejections {
.fa-icon-content(@fa-var-exclamation-circle);
}
}

Loading…
Cancel
Save