The Free Software Media System - Server Backend & API
fix playlist deletion
dkanada1b2453b4e90b
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.csindex 6942088fe8..b03b7e67eb 100644--- a/Emby.Server.Implementations/Library/LibraryManager.cs+++ b/Emby.Server.Implementations/Library/LibraryManager.cs@@ -394,7 +394,7 @@ namespace Emby.Server.Implementations.Libraryforeach (var fileSystemInfo in item.GetDeletePaths().ToList()){- if (File.Exists(fileSystemInfo.FullName))+ if (File.Exists(fileSystemInfo.FullName) || Directory.Exists(fileSystemInfo.FullName)){try{diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.csindex 0f58e43ed1..b26f4026c5 100644--- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs+++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs@@ -56,10 +56,8 @@ namespace Emby.Server.Implementations.Playlists{var name = options.Name;- var folderName = _fileSystem.GetValidFilename(name) + " [playlist]";-+ var folderName = _fileSystem.GetValidFilename(name);var parentFolder = GetPlaylistsFolder(Guid.Empty);-if (parentFolder == null){throw new ArgumentException();@@ -253,11 +251,13 @@ namespace Emby.Server.Implementations.PlaylistsSavePlaylistFile(playlist);}- _providerManager.QueueRefresh(playlist.Id, new MetadataRefreshOptions(new DirectoryService(_fileSystem))- {- ForceSave = true-- }, RefreshPriority.High);+ _providerManager.QueueRefresh(+ playlist.Id,+ new MetadataRefreshOptions(new DirectoryService(_fileSystem))+ {+ ForceSave = true+ },+ RefreshPriority.High);}public void MoveItem(string playlistId, string entryId, int newIndex)@@ -303,7 +303,8 @@ namespace Emby.Server.Implementations.Playlistsprivate void SavePlaylistFile(Playlist item){- // This is probably best done as a metatata provider, but saving a file over itself will first require some core work to prevent this from happening when not needed+ // this is probably best done as a metadata provider+ // saving a file over itself will require some work to prevent this from happening when not neededvar playlistPath = item.Path;var extension = Path.GetExtension(playlistPath);@@ -335,12 +336,14 @@ namespace Emby.Server.Implementations.Playlists{entry.Duration = TimeSpan.FromTicks(child.RunTimeTicks.Value);}+playlist.PlaylistEntries.Add(entry);}string text = new WplContent().ToText(playlist);File.WriteAllText(playlistPath, text);}+if (string.Equals(".zpl", extension, StringComparison.OrdinalIgnoreCase)){var playlist = new ZplPlaylist();@@ -375,6 +378,7 @@ namespace Emby.Server.Implementations.Playlistsstring text = new ZplContent().ToText(playlist);File.WriteAllText(playlistPath, text);}+if (string.Equals(".m3u", extension, StringComparison.OrdinalIgnoreCase)){var playlist = new M3uPlaylist();@@ -398,12 +402,14 @@ namespace Emby.Server.Implementations.Playlists{entry.Duration = TimeSpan.FromTicks(child.RunTimeTicks.Value);}+playlist.PlaylistEntries.Add(entry);}string text = new M3uContent().ToText(playlist);File.WriteAllText(playlistPath, text);}+if (string.Equals(".m3u8", extension, StringComparison.OrdinalIgnoreCase)){var playlist = new M3uPlaylist();@@ -427,12 +433,14 @@ namespace Emby.Server.Implementations.Playlists{entry.Duration = TimeSpan.FromTicks(child.RunTimeTicks.Value);}+playlist.PlaylistEntries.Add(entry);}string text = new M3u8Content().ToText(playlist);File.WriteAllText(playlistPath, text);}+if (string.Equals(".pls", extension, StringComparison.OrdinalIgnoreCase)){var playlist = new PlsPlaylist();@@ -448,6 +456,7 @@ namespace Emby.Server.Implementations.Playlists{entry.Length = TimeSpan.FromTicks(child.RunTimeTicks.Value);}+playlist.PlaylistEntries.Add(entry);}@@ -473,7 +482,7 @@ namespace Emby.Server.Implementations.Playliststhrow new ArgumentException("File absolute path was null or empty.", nameof(fileAbsolutePath));}- if (!folderPath.EndsWith(Path.DirectorySeparatorChar.ToString()))+ if (!folderPath.EndsWith(Path.DirectorySeparatorChar)){folderPath = folderPath + Path.DirectorySeparatorChar;}@@ -481,7 +490,11 @@ namespace Emby.Server.Implementations.Playlistsvar folderUri = new Uri(folderPath);var fileAbsoluteUri = new Uri(fileAbsolutePath);- if (folderUri.Scheme != fileAbsoluteUri.Scheme) { return fileAbsolutePath; } // path can't be made relative.+ // path can't be made relative+ if (folderUri.Scheme != fileAbsoluteUri.Scheme)+ {+ return fileAbsolutePath;+ }var relativeUri = folderUri.MakeRelativeUri(fileAbsoluteUri);string relativePath = Uri.UnescapeDataString(relativeUri.ToString());diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.csindex 0cc5e112f4..b1ea3e2627 100644--- a/MediaBrowser.Api/Library/LibraryService.cs+++ b/MediaBrowser.Api/Library/LibraryService.cs@@ -1006,8 +1006,8 @@ namespace MediaBrowser.Api.Librarypublic void Delete(DeleteItems request){var ids = string.IsNullOrWhiteSpace(request.Ids)- ? Array.Empty<string>()- : request.Ids.Split(',');+ ? Array.Empty<string>()+ : request.Ids.Split(',');foreach (var i in ids){@@ -1028,7 +1028,6 @@ namespace MediaBrowser.Api.Library_libraryManager.DeleteItem(item, new DeleteOptions{DeleteFileLocation = true-}, true);}}