mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-12 11:15:43 +02:00
Delete is setup, just need to add a link to follow through on the delete.
Removes EpisodeFiles, Episodes, Season and then the Series.
This commit is contained in:
parent
dbca3a1974
commit
88ad555e75
@ -37,6 +37,11 @@ public String CreateDirectory(string path)
|
|||||||
return Directory.CreateDirectory(path).FullName;
|
return Directory.CreateDirectory(path).FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteFile(string path)
|
||||||
|
{
|
||||||
|
File.Delete(path);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,7 +21,6 @@ public class EpisodeProvider : IEpisodeProvider
|
|||||||
private readonly IQualityProvider _quality;
|
private readonly IQualityProvider _quality;
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
|
||||||
public EpisodeProvider(IRepository sonicRepo, ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, ITvDbProvider tvDbProvider, IHistoryProvider history, IQualityProvider quality)
|
public EpisodeProvider(IRepository sonicRepo, ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, ITvDbProvider tvDbProvider, IHistoryProvider history, IQualityProvider quality)
|
||||||
{
|
{
|
||||||
_sonicRepo = sonicRepo;
|
_sonicRepo = sonicRepo;
|
||||||
@ -262,6 +261,11 @@ public void RefreshEpisodeInfo(Season season)
|
|||||||
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount);
|
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteEpisode(int episodeId)
|
||||||
|
{
|
||||||
|
_sonicRepo.Delete<Episode>(episodeId);
|
||||||
|
}
|
||||||
|
|
||||||
private bool IsSeasonIgnored(EpisodeModel episode)
|
private bool IsSeasonIgnored(EpisodeModel episode)
|
||||||
{
|
{
|
||||||
//Check if this Season is ignored
|
//Check if this Season is ignored
|
||||||
|
@ -11,5 +11,6 @@ public interface IDiskProvider
|
|||||||
string[] GetFiles(string path, string pattern, SearchOption searchOption);
|
string[] GetFiles(string path, string pattern, SearchOption searchOption);
|
||||||
bool FileExists(string path);
|
bool FileExists(string path);
|
||||||
long GetSize(string path);
|
long GetSize(string path);
|
||||||
|
void DeleteFile(string path);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,5 +22,6 @@ public interface IEpisodeProvider
|
|||||||
void RefreshEpisodeInfo(int seriesId);
|
void RefreshEpisodeInfo(int seriesId);
|
||||||
void RefreshEpisodeInfo(Season season);
|
void RefreshEpisodeInfo(Season season);
|
||||||
IList<Episode> GetEpisodeBySeason(long seasonId);
|
IList<Episode> GetEpisodeBySeason(long seasonId);
|
||||||
|
void DeleteEpisode(int episodeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,5 +13,7 @@ public interface IMediaFileProvider
|
|||||||
|
|
||||||
EpisodeFile ImportFile(Series series, string filePath);
|
EpisodeFile ImportFile(Series series, string filePath);
|
||||||
string GenerateEpisodePath(EpisodeModel episode);
|
string GenerateEpisodePath(EpisodeModel episode);
|
||||||
|
void DeleteFromDb(int fileId);
|
||||||
|
void DeleteFromDisk(int fileId, string path);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,5 +12,6 @@ public interface ISeasonProvider
|
|||||||
int SaveSeason(Season season);
|
int SaveSeason(Season season);
|
||||||
bool IsIgnored(int seasonId);
|
bool IsIgnored(int seasonId);
|
||||||
bool IsIgnored(int seriesId, int seasonNumber);
|
bool IsIgnored(int seriesId, int seasonNumber);
|
||||||
|
void DeleteSeason(int seasonId);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,5 +25,6 @@ public interface ISeriesProvider
|
|||||||
Series FindSeries(string cleanTitle);
|
Series FindSeries(string cleanTitle);
|
||||||
bool QualityWanted(int seriesId, QualityTypes quality);
|
bool QualityWanted(int seriesId, QualityTypes quality);
|
||||||
void UpdateSeries(Series series);
|
void UpdateSeries(Series series);
|
||||||
|
void DeleteSeries(int seriesId);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -112,6 +112,17 @@ public string GenerateEpisodePath(EpisodeModel episode)
|
|||||||
return String.Format(episodeNamePattern, episode.SeriesTitle, episode.EpisodeNumber, episode.SeasonNumber, episode.EpisodeTitle, episode.Quality);
|
return String.Format(episodeNamePattern, episode.SeriesTitle, episode.EpisodeNumber, episode.SeasonNumber, episode.EpisodeTitle, episode.Quality);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteFromDb(int fileId)
|
||||||
|
{
|
||||||
|
_repository.Delete<EpisodeFile>(fileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteFromDisk(int fileId, string path)
|
||||||
|
{
|
||||||
|
_diskProvider.DeleteFile(path);
|
||||||
|
_repository.Delete<EpisodeFile>(fileId);
|
||||||
|
}
|
||||||
|
|
||||||
private List<string> GetMediaFileList(string path)
|
private List<string> GetMediaFileList(string path)
|
||||||
{
|
{
|
||||||
Logger.Debug("Scanning '{0}' for episodes", path);
|
Logger.Debug("Scanning '{0}' for episodes", path);
|
||||||
|
@ -71,5 +71,10 @@ public bool IsIgnored(int seriesId, int seasonNumber)
|
|||||||
Logger.Debug("Season: {0} is not wanted for Series: {1}", seasonNumber, seriesId);
|
Logger.Debug("Season: {0} is not wanted for Series: {1}", seasonNumber, seriesId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteSeason(int seasonId)
|
||||||
|
{
|
||||||
|
_sonicRepo.Delete<Season>(seasonId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,9 +22,11 @@ public class SeriesProvider : ISeriesProvider
|
|||||||
private readonly IRepository _sonioRepo;
|
private readonly IRepository _sonioRepo;
|
||||||
private readonly ITvDbProvider _tvDb;
|
private readonly ITvDbProvider _tvDb;
|
||||||
private readonly IQualityProvider _quality;
|
private readonly IQualityProvider _quality;
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public SeriesProvider(IDiskProvider diskProvider, IConfigProvider configProvider, IRepository dataRepository, ITvDbProvider tvDbProvider, IQualityProvider quality)
|
public SeriesProvider(IDiskProvider diskProvider, IConfigProvider configProvider,
|
||||||
|
IRepository dataRepository, ITvDbProvider tvDbProvider, IQualityProvider quality)
|
||||||
{
|
{
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_config = configProvider;
|
_config = configProvider;
|
||||||
@ -122,6 +124,26 @@ public void UpdateSeries(Series series)
|
|||||||
_sonioRepo.Update(series);
|
_sonioRepo.Update(series);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteSeries(int seriesId)
|
||||||
|
{
|
||||||
|
var series = _sonioRepo.Single<Series>(seriesId);
|
||||||
|
|
||||||
|
//Delete Files, Episdes, Seasons then the Series
|
||||||
|
//Can't use providers because episode provider needs series provider - Cyclic Dependency Injection, this will work
|
||||||
|
|
||||||
|
Logger.Debug("Deleting EpisodeFiles from DB for Series: {0}", series.SeriesId);
|
||||||
|
_sonioRepo.DeleteMany(series.Files);
|
||||||
|
|
||||||
|
Logger.Debug("Deleting Episodes from DB for Series: {0}", series.SeriesId);
|
||||||
|
_sonioRepo.DeleteMany(series.Episodes);
|
||||||
|
|
||||||
|
Logger.Debug("Deleting Seasons from DB for Series: {0}", series.SeriesId);
|
||||||
|
_sonioRepo.DeleteMany(series.Seasons);
|
||||||
|
|
||||||
|
Logger.Debug("Deleting Series from DB {0}", series.Title);
|
||||||
|
_sonioRepo.Delete<Series>(seriesId);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Static Helpers
|
#region Static Helpers
|
||||||
|
@ -181,5 +181,13 @@ public ActionResult Edit(Series series)
|
|||||||
_seriesProvider.UpdateSeries(series);
|
_seriesProvider.UpdateSeries(series);
|
||||||
return Content("Series Updated Successfully");
|
return Content("Series Updated Successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResult Delete(int seriesId)
|
||||||
|
{
|
||||||
|
//Need to add seriesProvider.Update
|
||||||
|
_seriesProvider.DeleteSeries(seriesId);
|
||||||
|
|
||||||
|
return RedirectToAction("Index", "Series");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user