clean related files when deleting items

This commit is contained in:
Luke Pulverenti
2017-02-18 03:32:17 -05:00
parent 36f8eb1149
commit 6091e00e18
31 changed files with 161 additions and 295 deletions

View File

@@ -156,7 +156,7 @@ namespace MediaBrowser.Controller.Entities
{
if (SupportsIsInMixedFolderDetection)
{
}
return IsInMixedFolder;
@@ -2078,9 +2078,31 @@ namespace MediaBrowser.Controller.Entities
/// Gets the file system path to delete when the item is to be deleted
/// </summary>
/// <returns></returns>
public virtual IEnumerable<string> GetDeletePaths()
public virtual IEnumerable<FileSystemMetadata> GetDeletePaths()
{
return new[] { Path };
return new[] {
new FileSystemMetadata
{
FullName = Path,
IsDirectory = IsFolder
}
}.Concat(GetLocalMetadataFilesToDelete());
}
protected List<FileSystemMetadata> GetLocalMetadataFilesToDelete()
{
if (IsFolder || !IsInMixedFolder)
{
return new List<FileSystemMetadata>();
}
var filename = System.IO.Path.GetFileNameWithoutExtension(Path);
var extensions = new[] { ".nfo", ".xml", ".srt" }.ToList();
extensions.AddRange(SupportedImageExtensionsList);
return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path))
.Where(i => extensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase) && System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase))
.ToList();
}
public bool AllowsMultipleImages(ImageType type)

View File

@@ -4,6 +4,7 @@ using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Controller.Entities
@@ -97,11 +98,17 @@ namespace MediaBrowser.Controller.Entities
return list;
}
public override IEnumerable<string> GetDeletePaths()
public override IEnumerable<FileSystemMetadata> GetDeletePaths()
{
if (!DetectIsInMixedFolder())
{
return new[] { System.IO.Path.GetDirectoryName(Path) };
return new[] {
new FileSystemMetadata
{
FullName = System.IO.Path.GetDirectoryName(Path),
IsDirectory = true
}
};
}
return base.GetDeletePaths();

View File

@@ -141,7 +141,7 @@ namespace MediaBrowser.Controller.Entities
public string ExternalSeriesId { get; set; }
public string ExternalId { get; set; }
public string[] AlbumNames { get; set; }
public string[] AlbumIds { get; set; }
public string[] ArtistIds { get; set; }
public string[] ExcludeArtistIds { get; set; }
public string AncestorWithPresentationUniqueKey { get; set; }
@@ -202,7 +202,7 @@ namespace MediaBrowser.Controller.Entities
EnableTotalRecordCount = true;
DtoOptions = new DtoOptions();
AlbumNames = new string[] { };
AlbumIds = new string[] { };
ArtistIds = new string[] { };
ExcludeArtistIds = new string[] { };
ExcludeProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

View File

@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Controller.Entities.TV
@@ -319,10 +320,16 @@ namespace MediaBrowser.Controller.Entities.TV
return list;
}
public override IEnumerable<string> GetDeletePaths()
{
return new[] { Path };
}
public override IEnumerable<FileSystemMetadata> GetDeletePaths()
{
return new[] {
new FileSystemMetadata
{
FullName = Path,
IsDirectory = IsFolder
}
}.Concat(GetLocalMetadataFilesToDelete());
}
public override UnratedItem GetBlockUnratedType()
{
@@ -338,7 +345,6 @@ namespace MediaBrowser.Controller.Entities.TV
if (series != null)
{
id.SeriesProviderIds = series.ProviderIds;
id.AnimeSeriesIndex = series.AnimeSeriesIndex;
}
id.IsMissingEpisode = IsMissingEpisode;

View File

@@ -251,7 +251,6 @@ namespace MediaBrowser.Controller.Entities.TV
if (series != null)
{
id.SeriesProviderIds = series.ProviderIds;
id.AnimeSeriesIndex = series.AnimeSeriesIndex;
}
return id;

View File

@@ -19,8 +19,6 @@ namespace MediaBrowser.Controller.Entities.TV
/// </summary>
public class Series : Folder, IHasTrailers, IHasDisplayOrder, IHasLookupInfo<SeriesInfo>, IMetadataContainer
{
public int? AnimeSeriesIndex { get; set; }
public Series()
{
AirDays = new List<DayOfWeek>();
@@ -554,8 +552,6 @@ namespace MediaBrowser.Controller.Entities.TV
{
var info = GetItemLookupInfo<SeriesInfo>();
info.AnimeSeriesIndex = AnimeSeriesIndex;
return info;
}

View File

@@ -1719,53 +1719,6 @@ namespace MediaBrowser.Controller.Entities
}
}
// Artists
if (query.ArtistIds.Length > 0)
{
var audio = item as IHasArtist;
//if (!(audio != null && query.ArtistNames.Any(audio.HasAnyArtist)))
//{
// return false;
//}
}
// Albums
if (query.AlbumNames.Length > 0)
{
var audio = item as Audio.Audio;
if (audio != null)
{
if (!query.AlbumNames.Any(a => string.Equals(a, audio.Album, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
}
var album = item as MusicAlbum;
if (album != null)
{
if (!query.AlbumNames.Any(a => string.Equals(a, album.Name, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
}
var musicVideo = item as MusicVideo;
if (musicVideo != null)
{
if (!query.AlbumNames.Any(a => string.Equals(a, musicVideo.Album, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
}
return false;
}
return true;
}

View File

@@ -477,11 +477,17 @@ namespace MediaBrowser.Controller.Entities
}
}
public override IEnumerable<string> GetDeletePaths()
public override IEnumerable<FileSystemMetadata> GetDeletePaths()
{
if (!DetectIsInMixedFolder())
{
return new[] { ContainingFolderPath };
return new[] {
new FileSystemMetadata
{
FullName = System.IO.Path.GetDirectoryName(Path),
IsDirectory = true
}
};
}
return base.GetDeletePaths();

View File

@@ -8,7 +8,6 @@ namespace MediaBrowser.Controller.Providers
public Dictionary<string, string> SeriesProviderIds { get; set; }
public int? IndexNumberEnd { get; set; }
public int? AnimeSeriesIndex { get; set; }
public bool IsMissingEpisode { get; set; }
public bool IsVirtualUnaired { get; set; }

View File

@@ -6,7 +6,6 @@ namespace MediaBrowser.Controller.Providers
public class SeasonInfo : ItemLookupInfo
{
public Dictionary<string, string> SeriesProviderIds { get; set; }
public int? AnimeSeriesIndex { get; set; }
public SeasonInfo()
{

View File

@@ -2,6 +2,5 @@ namespace MediaBrowser.Controller.Providers
{
public class SeriesInfo : ItemLookupInfo
{
public int? AnimeSeriesIndex { get; set; }
}
}