Fixed: Rename TrackFiles in DB on artist move

Fixes #1012
This commit is contained in:
ta264 2020-02-09 19:15:43 +00:00 committed by Qstick
parent be4e748977
commit ffc67899d1
1 changed files with 14 additions and 0 deletions

View File

@ -35,6 +35,7 @@ namespace NzbDrone.Core.MediaFiles
} }
public class MediaFileService : IMediaFileService, public class MediaFileService : IMediaFileService,
IHandle<ArtistMovedEvent>,
IHandleAsync<AlbumDeletedEvent>, IHandleAsync<AlbumDeletedEvent>,
IHandleAsync<ModelEvent<RootFolder>> IHandleAsync<ModelEvent<RootFolder>>
{ {
@ -200,6 +201,19 @@ namespace NzbDrone.Core.MediaFiles
_mediaFileRepository.SetFields(trackFiles, t => t.MediaInfo); _mediaFileRepository.SetFields(trackFiles, t => t.MediaInfo);
} }
public void Handle(ArtistMovedEvent message)
{
var files = _mediaFileRepository.GetFilesWithBasePath(message.SourcePath);
foreach (var file in files)
{
var newPath = message.DestinationPath + file.Path.Substring(message.SourcePath.Length);
file.Path = newPath;
}
Update(files);
}
public void HandleAsync(AlbumDeletedEvent message) public void HandleAsync(AlbumDeletedEvent message)
{ {
if (message.DeleteFiles) if (message.DeleteFiles)