diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-12-01 14:31:58 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-12-01 14:31:58 -0500 |
| commit | 7ac2f7481734694ae411f5481c6a73264671b55b (patch) | |
| tree | c9c5a2f32e4a8e41b81da4f5e4abfc9cedcaf66c | |
| parent | e191836ea0405c5a152a742fc5526d8ceb5c5db5 (diff) | |
fixes #629 - Deleting a movie only deletes the video file
| -rw-r--r-- | MediaBrowser.Api/LibraryService.cs | 15 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 9 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Game.cs | 12 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/TV/Episode.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Video.cs | 9 |
5 files changed, 43 insertions, 7 deletions
diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs index 55ee454d2..cf62e42ba 100644 --- a/MediaBrowser.Api/LibraryService.cs +++ b/MediaBrowser.Api/LibraryService.cs @@ -465,13 +465,16 @@ namespace MediaBrowser.Api if (item.LocationType == LocationType.FileSystem) { - if (Directory.Exists(item.Path)) + foreach (var path in item.GetDeletePaths().ToList()) { - Directory.Delete(item.Path, true); - } - else if (File.Exists(item.Path)) - { - File.Delete(item.Path); + if (Directory.Exists(path)) + { + Directory.Delete(path, true); + } + else if (File.Exists(path)) + { + File.Delete(path); + } } if (parent != null) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 3f0613643..d88282429 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1765,5 +1765,14 @@ namespace MediaBrowser.Controller.Entities // See if we can avoid a file system lookup by looking for the file in ResolveArgs return metaFileEntry == null ? FileSystem.GetLastWriteTimeUtc(imagePath) : FileSystem.GetLastWriteTimeUtc(metaFileEntry); } + + /// <summary> + /// Gets the file system path to delete when the item is to be deleted + /// </summary> + /// <returns></returns> + public virtual IEnumerable<string> GetDeletePaths() + { + return new[] { Path }; + } } } diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index e8374c274..ea39cf50a 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Entities public class Game : BaseItem, IHasSoundtracks { public List<Guid> SoundtrackIds { get; set; } - + public Game() { MultiPartGameFiles = new List<string>(); @@ -84,5 +84,15 @@ namespace MediaBrowser.Controller.Entities } return base.GetUserDataKey(); } + + public override IEnumerable<string> GetDeletePaths() + { + if (!IsInMixedFolder) + { + return new[] { System.IO.Path.GetDirectoryName(Path) }; + } + + return base.GetDeletePaths(); + } } } diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index f090ce2a2..5eab1cae0 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -248,5 +248,10 @@ namespace MediaBrowser.Controller.Entities.TV { get { return LocationType == Model.Entities.LocationType.Virtual && IsUnaired; } } + + public override IEnumerable<string> GetDeletePaths() + { + return new[] { Path }; + } } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 6a27ed690..ef768f628 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -258,5 +258,14 @@ namespace MediaBrowser.Controller.Entities }).ToList(); } + public override IEnumerable<string> GetDeletePaths() + { + if (!IsInMixedFolder) + { + return new[] { System.IO.Path.GetDirectoryName(Path) }; + } + + return base.GetDeletePaths(); + } } } |
