mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-05 07:18:47 +01:00
clean related files when deleting items
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -251,7 +251,6 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
if (series != null)
|
||||
{
|
||||
id.SeriesProviderIds = series.ProviderIds;
|
||||
id.AnimeSeriesIndex = series.AnimeSeriesIndex;
|
||||
}
|
||||
|
||||
return id;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,5 @@ namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
public class SeriesInfo : ItemLookupInfo
|
||||
{
|
||||
public int? AnimeSeriesIndex { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user