mirror of https://github.com/lidarr/Lidarr
New: Store track renames in History
This commit is contained in:
parent
257af8b914
commit
57aaf62a46
|
@ -40,6 +40,7 @@ namespace NzbDrone.Core.History
|
||||||
SeriesFolderImported = 2,
|
SeriesFolderImported = 2,
|
||||||
DownloadFolderImported = 3,
|
DownloadFolderImported = 3,
|
||||||
DownloadFailed = 4,
|
DownloadFailed = 4,
|
||||||
TrackFileDeleted = 5
|
TrackFileDeleted = 5,
|
||||||
|
TrackFileRenamed = 6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace NzbDrone.Core.History
|
||||||
IHandle<TrackImportedEvent>,
|
IHandle<TrackImportedEvent>,
|
||||||
IHandle<DownloadFailedEvent>,
|
IHandle<DownloadFailedEvent>,
|
||||||
IHandle<TrackFileDeletedEvent>,
|
IHandle<TrackFileDeletedEvent>,
|
||||||
|
IHandle<TrackFileRenamedEvent>,
|
||||||
IHandle<ArtistDeletedEvent>
|
IHandle<ArtistDeletedEvent>
|
||||||
{
|
{
|
||||||
private readonly IHistoryRepository _historyRepository;
|
private readonly IHistoryRepository _historyRepository;
|
||||||
|
@ -253,6 +254,35 @@ namespace NzbDrone.Core.History
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Handle(TrackFileRenamedEvent message)
|
||||||
|
{
|
||||||
|
var sourcePath = message.OriginalPath;
|
||||||
|
var sourceRelativePath = message.Artist.Path.GetRelativePath(message.OriginalPath);
|
||||||
|
var path = Path.Combine(message.Artist.Path, message.TrackFile.RelativePath);
|
||||||
|
var relativePath = message.TrackFile.RelativePath;
|
||||||
|
|
||||||
|
foreach (var track in message.TrackFile.Tracks.Value)
|
||||||
|
{
|
||||||
|
var history = new History
|
||||||
|
{
|
||||||
|
EventType = HistoryEventType.TrackFileRenamed,
|
||||||
|
Date = DateTime.UtcNow,
|
||||||
|
Quality = message.TrackFile.Quality,
|
||||||
|
SourceTitle = message.OriginalPath,
|
||||||
|
ArtistId = message.TrackFile.ArtistId,
|
||||||
|
AlbumId = message.TrackFile.AlbumId,
|
||||||
|
TrackId = track.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(ArtistDeletedEvent message)
|
public void Handle(ArtistDeletedEvent message)
|
||||||
{
|
{
|
||||||
_historyRepository.DeleteForArtist(message.Artist.Id);
|
_historyRepository.DeleteForArtist(message.Artist.Id);
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
using NzbDrone.Common.Messaging;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.MediaFiles.Events
|
||||||
|
{
|
||||||
|
public class TrackFileRenamedEvent : IEvent
|
||||||
|
{
|
||||||
|
public Artist Artist { get; private set; }
|
||||||
|
public TrackFile TrackFile { get; private set; }
|
||||||
|
public string OriginalPath { get; private set; }
|
||||||
|
|
||||||
|
public TrackFileRenamedEvent(Artist artist, TrackFile trackFile, string originalPath)
|
||||||
|
{
|
||||||
|
Artist = artist;
|
||||||
|
TrackFile = trackFile;
|
||||||
|
OriginalPath = originalPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -129,6 +129,8 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
renamed.Add(trackFile);
|
renamed.Add(trackFile);
|
||||||
|
|
||||||
_logger.Debug("Renamed track file: {0}", trackFile);
|
_logger.Debug("Renamed track file: {0}", trackFile);
|
||||||
|
|
||||||
|
_eventAggregator.PublishEvent(new TrackFileRenamedEvent(artist, trackFile, trackFilePath));
|
||||||
}
|
}
|
||||||
catch (SameFilenameException ex)
|
catch (SameFilenameException ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -620,6 +620,7 @@
|
||||||
<Compile Include="MediaFiles\Commands\CleanUpRecycleBinCommand.cs" />
|
<Compile Include="MediaFiles\Commands\CleanUpRecycleBinCommand.cs" />
|
||||||
<Compile Include="MediaFiles\Commands\DownloadedAlbumsScanCommand.cs" />
|
<Compile Include="MediaFiles\Commands\DownloadedAlbumsScanCommand.cs" />
|
||||||
<Compile Include="MediaFiles\Commands\RenameArtistCommand.cs" />
|
<Compile Include="MediaFiles\Commands\RenameArtistCommand.cs" />
|
||||||
|
<Compile Include="MediaFiles\Events\TrackFileRenamedEvent.cs" />
|
||||||
<Compile Include="MediaFiles\Events\TrackFolderCreatedEvent.cs" />
|
<Compile Include="MediaFiles\Events\TrackFolderCreatedEvent.cs" />
|
||||||
<Compile Include="MediaFiles\MediaFileDeletionService.cs" />
|
<Compile Include="MediaFiles\MediaFileDeletionService.cs" />
|
||||||
<Compile Include="MediaFiles\MediaInfo\MediaInfoFormatter.cs" />
|
<Compile Include="MediaFiles\MediaInfo\MediaInfoFormatter.cs" />
|
||||||
|
|
Loading…
Reference in New Issue