Merge conflicts

pull/7/head
Joseph Milazzo 8 years ago
commit dc0db08ca8

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
@ -8,7 +8,7 @@ namespace NzbDrone.Core.MediaFiles
{ {
public interface IMediaFileRepository : IBasicRepository<TrackFile> public interface IMediaFileRepository : IBasicRepository<TrackFile>
{ {
List<TrackFile> GetFilesByArtist(string artistId); List<TrackFile> GetFilesByArtist(int artistId);
List<TrackFile> GetFilesWithoutMediaInfo(); List<TrackFile> GetFilesWithoutMediaInfo();
} }
@ -25,9 +25,9 @@ namespace NzbDrone.Core.MediaFiles
return Query.Where(c => c.MediaInfo == null).ToList(); return Query.Where(c => c.MediaInfo == null).ToList();
} }
public List<TrackFile> GetFilesByArtist(string artistId) public List<TrackFile> GetFilesByArtist(int artistId)
{ {
return Query.Where(c => c.ForeignTrackId == artistId).ToList(); return Query.Where(c => c.ArtistId == artistId).ToList();
} }
} }
} }

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using NLog; using NLog;
@ -18,7 +18,7 @@ namespace NzbDrone.Core.MediaFiles
TrackFile Add(TrackFile trackFile); TrackFile Add(TrackFile trackFile);
void Update(TrackFile trackFile); void Update(TrackFile trackFile);
void Delete(TrackFile trackFile, DeleteMediaFileReason reason); void Delete(TrackFile trackFile, DeleteMediaFileReason reason);
List<TrackFile> GetFilesByArtist(string artistId); List<TrackFile> GetFilesByArtist(int artistId);
List<TrackFile> GetFilesWithoutMediaInfo(); List<TrackFile> GetFilesWithoutMediaInfo();
List<string> FilterExistingFiles(List<string> files, Artist artist); List<string> FilterExistingFiles(List<string> files, Artist artist);
TrackFile Get(int id); TrackFile Get(int id);
@ -69,7 +69,11 @@ namespace NzbDrone.Core.MediaFiles
public List<string> FilterExistingFiles(List<string> files, Artist artist) public List<string> FilterExistingFiles(List<string> files, Artist artist)
{ {
<<<<<<< HEAD
var artistFiles = GetFilesByArtist(artist.ForeignArtistId).Select(f => Path.Combine(artist.Path, f.RelativePath)).ToList(); var artistFiles = GetFilesByArtist(artist.ForeignArtistId).Select(f => Path.Combine(artist.Path, f.RelativePath)).ToList();
=======
var artistFiles = GetFilesByArtist(artist.Id).Select(f => Path.Combine(artist.Path, f.RelativePath)).ToList();
>>>>>>> fafe4e93f34fea769c9a64d9a98015821738b1e4
if (!artistFiles.Any()) return files; if (!artistFiles.Any()) return files;
@ -89,11 +93,11 @@ namespace NzbDrone.Core.MediaFiles
public void HandleAsync(ArtistDeletedEvent message) public void HandleAsync(ArtistDeletedEvent message)
{ {
var files = GetFilesByArtist(message.Artist.ForeignArtistId); var files = GetFilesByArtist(message.Artist.Id);
_mediaFileRepository.DeleteMany(files); _mediaFileRepository.DeleteMany(files);
} }
public List<TrackFile> GetFilesByArtist(string artistId) public List<TrackFile> GetFilesByArtist(int artistId)
{ {
return _mediaFileRepository.GetFilesByArtist(artistId); return _mediaFileRepository.GetFilesByArtist(artistId);
} }

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using NLog; using NLog;
@ -31,8 +31,9 @@ namespace NzbDrone.Core.MediaFiles
public void Clean(Artist artist, List<string> filesOnDisk) public void Clean(Artist artist, List<string> filesOnDisk)
{ {
var artistFiles = _mediaFileService.GetFilesByArtist(artist.ForeignArtistId); var artistFiles = _mediaFileService.GetFilesByArtist(artist.Id);
var tracks = _trackService.GetTracksByArtist(artist.ForeignArtistId); var tracks = _trackService.GetTracksByArtist(artist.Id);
var filesOnDiskKeys = new HashSet<string>(filesOnDisk, PathEqualityComparer.Instance); var filesOnDiskKeys = new HashSet<string>(filesOnDisk, PathEqualityComparer.Instance);

@ -65,7 +65,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return; return;
} }
var allMediaFiles = _mediaFileService.GetFilesByArtist(message.Artist.ForeignArtistId); var allMediaFiles = _mediaFileService.GetFilesByArtist(message.Artist.Id);
var filteredMediaFiles = allMediaFiles.Where(c => c.MediaInfo == null || c.MediaInfo.SchemaRevision < CURRENT_MEDIA_INFO_SCHEMA_REVISION).ToList(); var filteredMediaFiles = allMediaFiles.Where(c => c.MediaInfo == null || c.MediaInfo.SchemaRevision < CURRENT_MEDIA_INFO_SCHEMA_REVISION).ToList();
UpdateMediaInfo(message.Artist, filteredMediaFiles); UpdateMediaInfo(message.Artist, filteredMediaFiles);

@ -15,6 +15,7 @@ namespace NzbDrone.Core.MediaFiles
public string ForeignTrackId { get; set; } public string ForeignTrackId { get; set; }
public string ForeignArtistId { get; set; } public string ForeignArtistId { get; set; }
public int AlbumId { get; set; } public int AlbumId { get; set; }
public int ArtistId { get; set; }
public string RelativePath { get; set; } public string RelativePath { get; set; }
public string Path { get; set; } public string Path { get; set; }
public long Size { get; set; } public long Size { get; set; }

@ -67,7 +67,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
.Intersect(localTrack.Tracks.Select(e => e.Id)) .Intersect(localTrack.Tracks.Select(e => e.Id))
.Any()) .Any())
{ {
importResults.Add(new ImportResult(importDecision, "Episode has already been imported")); importResults.Add(new ImportResult(importDecision, "Track has already been imported"));
continue; continue;
} }
@ -78,7 +78,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
trackFile.Size = _diskProvider.GetFileSize(localTrack.Path); trackFile.Size = _diskProvider.GetFileSize(localTrack.Path);
trackFile.Quality = localTrack.Quality; trackFile.Quality = localTrack.Quality;
trackFile.MediaInfo = localTrack.MediaInfo; trackFile.MediaInfo = localTrack.MediaInfo;
//trackFile.AlbumId = localTrack.Album.ElementAt(0); // TODO: Implement ImportApprovedTracks Album Id trackFile.AlbumId = localTrack.Album.Id;
trackFile.Tracks = localTrack.Tracks; trackFile.Tracks = localTrack.Tracks;
trackFile.ReleaseGroup = localTrack.ParsedTrackInfo.ReleaseGroup; trackFile.ReleaseGroup = localTrack.ParsedTrackInfo.ReleaseGroup;

@ -115,7 +115,7 @@ namespace NzbDrone.Core.Music
if (storedAlbum != null && album.Monitored != storedAlbum.Monitored) if (storedAlbum != null && album.Monitored != storedAlbum.Monitored)
{ {
_trackService.SetTrackMonitoredByAlbum(artist.ForeignArtistId, album.ForeignAlbumId, album.Monitored); _trackService.SetTrackMonitoredByAlbum(artist.Id, album.Id, album.Monitored);
} }
} }

@ -13,15 +13,15 @@ namespace NzbDrone.Core.Music
{ {
public interface ITrackRepository : IBasicRepository<Track> public interface ITrackRepository : IBasicRepository<Track>
{ {
Track Find(string artistId, string albumId, int trackNumber); Track Find(int artistId, int albumId, int trackNumber);
List<Track> GetTracks(string artistId); List<Track> GetTracks(int artistId);
List<Track> GetTracks(string artistId, string albumId); List<Track> GetTracks(int artistId, int albumId);
List<Track> GetTracksByFileId(int fileId); List<Track> GetTracksByFileId(int fileId);
List<Track> TracksWithFiles(string artistId); List<Track> TracksWithFiles(int artistId);
PagingSpec<Track> TracksWithoutFiles(PagingSpec<Track> pagingSpec); PagingSpec<Track> TracksWithoutFiles(PagingSpec<Track> pagingSpec);
PagingSpec<Track> TracksWhereCutoffUnmet(PagingSpec<Track> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff); PagingSpec<Track> TracksWhereCutoffUnmet(PagingSpec<Track> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff);
void SetMonitoredFlat(Track episode, bool monitored); void SetMonitoredFlat(Track episode, bool monitored);
void SetMonitoredByAlbum(string artistId, string albumId, bool monitored); void SetMonitoredByAlbum(int artistId, int albumId, bool monitored);
void SetFileId(int trackId, int fileId); void SetFileId(int trackId, int fileId);
} }
@ -37,24 +37,24 @@ namespace NzbDrone.Core.Music
_logger = logger; _logger = logger;
} }
public Track Find(string artistId, string albumId, int trackNumber) public Track Find(int artistId, int albumId, int trackNumber)
{ {
return Query.Where(s => s.ForeignTrackId == artistId) return Query.Where(s => s.ArtistId == artistId)
.AndWhere(s => s.Album.ForeignAlbumId == albumId) .AndWhere(s => s.AlbumId == albumId)
.AndWhere(s => s.TrackNumber == trackNumber) .AndWhere(s => s.TrackNumber == trackNumber)
.SingleOrDefault(); .SingleOrDefault();
} }
public List<Track> GetTracks(string artistId) public List<Track> GetTracks(int artistId)
{ {
return Query.Join<Track, Artist>(JoinType.Inner, s => s.Artist, (track, artist) => track.ArtistId == artist.Id).ToList(); return Query.Join<Track, Artist>(JoinType.Inner, s => s.Artist, (track, artist) => track.ArtistId == artist.Id).ToList();
} }
public List<Track> GetTracks(string artistId, string albumId) public List<Track> GetTracks(int artistId, int albumId)
{ {
return Query.Where(s => s.ForeignTrackId == artistId) return Query.Where(s => s.ArtistId == artistId)
.AndWhere(s => s.Album.ForeignAlbumId == albumId) .AndWhere(s => s.AlbumId == albumId)
.ToList(); .ToList();
} }
@ -63,10 +63,10 @@ namespace NzbDrone.Core.Music
return Query.Where(e => e.TrackFileId == fileId).ToList(); return Query.Where(e => e.TrackFileId == fileId).ToList();
} }
public List<Track> TracksWithFiles(string artistId) public List<Track> TracksWithFiles(int artistId)
{ {
return Query.Join<Track, TrackFile>(JoinType.Inner, e => e.TrackFile, (e, ef) => e.TrackFileId == ef.Id) return Query.Join<Track, TrackFile>(JoinType.Inner, e => e.TrackFile, (e, ef) => e.TrackFileId == ef.Id)
.Where(e => e.ForeignTrackId == artistId); .Where(e => e.ArtistId == artistId);
} }
public PagingSpec<Track> TracksWhereCutoffUnmet(PagingSpec<Track> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff) public PagingSpec<Track> TracksWhereCutoffUnmet(PagingSpec<Track> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff)
@ -85,7 +85,7 @@ namespace NzbDrone.Core.Music
SetFields(track, p => p.Monitored); SetFields(track, p => p.Monitored);
} }
public void SetMonitoredByAlbum(string artistId, string albumId, bool monitored) public void SetMonitoredByAlbum(int artistId, int albumId, bool monitored)
{ {
var mapper = _database.GetDataMapper(); var mapper = _database.GetDataMapper();

@ -15,12 +15,12 @@ namespace NzbDrone.Core.Music
{ {
Track GetTrack(int id); Track GetTrack(int id);
List<Track> GetTracks(IEnumerable<int> ids); List<Track> GetTracks(IEnumerable<int> ids);
Track FindTrack(string artistId, string albumId, int trackNumber); Track FindTrack(int artistId, int albumId, int trackNumber);
Track FindTrackByTitle(string artistId, string albumId, string releaseTitle); Track FindTrackByTitle(int artistId, int albumId, string releaseTitle);
List<Track> GetTracksByArtist(string artistId); List<Track> GetTracksByArtist(int artistId);
List<Track> GetTracksByAlbum(string artistId, string albumId); List<Track> GetTracksByAlbum(int artistId, int albumId);
//List<Track> GetTracksByAlbumTitle(string artistId, string albumTitle); //List<Track> GetTracksByAlbumTitle(string artistId, string albumTitle);
List<Track> TracksWithFiles(string artistId); List<Track> TracksWithFiles(int artistId);
//PagingSpec<Track> TracksWithoutFiles(PagingSpec<Track> pagingSpec); //PagingSpec<Track> TracksWithoutFiles(PagingSpec<Track> pagingSpec);
List<Track> GetTracksByFileId(int trackFileId); List<Track> GetTracksByFileId(int trackFileId);
void UpdateTrack(Track track); void UpdateTrack(Track track);
@ -29,7 +29,7 @@ namespace NzbDrone.Core.Music
void InsertMany(List<Track> tracks); void InsertMany(List<Track> tracks);
void UpdateMany(List<Track> tracks); void UpdateMany(List<Track> tracks);
void DeleteMany(List<Track> tracks); void DeleteMany(List<Track> tracks);
void SetTrackMonitoredByAlbum(string artistId, string albumId, bool monitored); void SetTrackMonitoredByAlbum(int artistId, int albumId, bool monitored);
} }
public class TrackService : ITrackService public class TrackService : ITrackService
@ -55,22 +55,22 @@ namespace NzbDrone.Core.Music
return _trackRepository.Get(ids).ToList(); return _trackRepository.Get(ids).ToList();
} }
public Track FindTrack(string artistId, string albumId, int trackNumber) public Track FindTrack(int artistId, int albumId, int trackNumber)
{ {
return _trackRepository.Find(artistId, albumId, trackNumber); return _trackRepository.Find(artistId, albumId, trackNumber);
} }
public List<Track> GetTracksByArtist(string artistId) public List<Track> GetTracksByArtist(int artistId)
{ {
return _trackRepository.GetTracks(artistId).ToList(); return _trackRepository.GetTracks(artistId).ToList();
} }
public List<Track> GetTracksByAlbum(string artistId, string albumId) public List<Track> GetTracksByAlbum(int artistId, int albumId)
{ {
return _trackRepository.GetTracks(artistId, albumId); return _trackRepository.GetTracks(artistId, albumId);
} }
public Track FindTrackByTitle(string artistId, string albumId, string releaseTitle) public Track FindTrackByTitle(int artistId, int albumId, string releaseTitle)
{ {
// TODO: can replace this search mechanism with something smarter/faster/better // TODO: can replace this search mechanism with something smarter/faster/better
var normalizedReleaseTitle = Parser.Parser.NormalizeEpisodeTitle(releaseTitle).Replace(".", " "); var normalizedReleaseTitle = Parser.Parser.NormalizeEpisodeTitle(releaseTitle).Replace(".", " ");
@ -96,7 +96,7 @@ namespace NzbDrone.Core.Music
return null; return null;
} }
public List<Track> TracksWithFiles(string artistId) public List<Track> TracksWithFiles(int artistId)
{ {
return _trackRepository.TracksWithFiles(artistId); return _trackRepository.TracksWithFiles(artistId);
} }
@ -127,7 +127,7 @@ namespace NzbDrone.Core.Music
_logger.Debug("Monitored flag for Track:{0} was set to {1}", trackId, monitored); _logger.Debug("Monitored flag for Track:{0} was set to {1}", trackId, monitored);
} }
public void SetTrackMonitoredByAlbum(string artistId, string albumId, bool monitored) public void SetTrackMonitoredByAlbum(int artistId, int albumId, bool monitored)
{ {
_trackRepository.SetMonitoredByAlbum(artistId, albumId, monitored); _trackRepository.SetMonitoredByAlbum(artistId, albumId, monitored);
} }
@ -154,7 +154,7 @@ namespace NzbDrone.Core.Music
public void HandleAsync(ArtistDeletedEvent message) public void HandleAsync(ArtistDeletedEvent message)
{ {
var tracks = GetTracksByArtist(message.Artist.ForeignArtistId); var tracks = GetTracksByArtist(message.Artist.Id);
_trackRepository.DeleteMany(tracks); _trackRepository.DeleteMany(tracks);
} }

Loading…
Cancel
Save