mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-23 14:10:40 +02:00
Merge pull request #2153 from dkanada/fix-playlist
Fix playlist deletion and a few warning fixes
This commit is contained in:
commit
529cff3920
|
@ -392,9 +392,9 @@ namespace Emby.Server.Implementations.Library
|
||||||
// Add this flag to GetDeletePaths if required in the future
|
// Add this flag to GetDeletePaths if required in the future
|
||||||
var isRequiredForDelete = true;
|
var isRequiredForDelete = true;
|
||||||
|
|
||||||
foreach (var fileSystemInfo in item.GetDeletePaths().ToList())
|
foreach (var fileSystemInfo in item.GetDeletePaths())
|
||||||
{
|
{
|
||||||
if (File.Exists(fileSystemInfo.FullName))
|
if (Directory.Exists(fileSystemInfo.FullName) || File.Exists(fileSystemInfo.FullName))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,10 +56,8 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
{
|
{
|
||||||
var name = options.Name;
|
var name = options.Name;
|
||||||
|
|
||||||
var folderName = _fileSystem.GetValidFilename(name) + " [playlist]";
|
var folderName = _fileSystem.GetValidFilename(name);
|
||||||
|
|
||||||
var parentFolder = GetPlaylistsFolder(Guid.Empty);
|
var parentFolder = GetPlaylistsFolder(Guid.Empty);
|
||||||
|
|
||||||
if (parentFolder == null)
|
if (parentFolder == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException();
|
throw new ArgumentException();
|
||||||
|
@ -253,11 +251,13 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
SavePlaylistFile(playlist);
|
SavePlaylistFile(playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
_providerManager.QueueRefresh(playlist.Id, new MetadataRefreshOptions(new DirectoryService(_fileSystem))
|
_providerManager.QueueRefresh(
|
||||||
{
|
playlist.Id,
|
||||||
ForceSave = true
|
new MetadataRefreshOptions(new DirectoryService(_fileSystem))
|
||||||
|
{
|
||||||
}, RefreshPriority.High);
|
ForceSave = true
|
||||||
|
},
|
||||||
|
RefreshPriority.High);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveItem(string playlistId, string entryId, int newIndex)
|
public void MoveItem(string playlistId, string entryId, int newIndex)
|
||||||
|
@ -303,7 +303,8 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
|
|
||||||
private void SavePlaylistFile(Playlist item)
|
private 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 needed
|
||||||
var playlistPath = item.Path;
|
var playlistPath = item.Path;
|
||||||
var extension = Path.GetExtension(playlistPath);
|
var extension = Path.GetExtension(playlistPath);
|
||||||
|
|
||||||
|
@ -335,12 +336,14 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
{
|
{
|
||||||
entry.Duration = TimeSpan.FromTicks(child.RunTimeTicks.Value);
|
entry.Duration = TimeSpan.FromTicks(child.RunTimeTicks.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist.PlaylistEntries.Add(entry);
|
playlist.PlaylistEntries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
string text = new WplContent().ToText(playlist);
|
string text = new WplContent().ToText(playlist);
|
||||||
File.WriteAllText(playlistPath, text);
|
File.WriteAllText(playlistPath, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(".zpl", extension, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(".zpl", extension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var playlist = new ZplPlaylist();
|
var playlist = new ZplPlaylist();
|
||||||
|
@ -375,6 +378,7 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
string text = new ZplContent().ToText(playlist);
|
string text = new ZplContent().ToText(playlist);
|
||||||
File.WriteAllText(playlistPath, text);
|
File.WriteAllText(playlistPath, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(".m3u", extension, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(".m3u", extension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var playlist = new M3uPlaylist();
|
var playlist = new M3uPlaylist();
|
||||||
|
@ -398,12 +402,14 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
{
|
{
|
||||||
entry.Duration = TimeSpan.FromTicks(child.RunTimeTicks.Value);
|
entry.Duration = TimeSpan.FromTicks(child.RunTimeTicks.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist.PlaylistEntries.Add(entry);
|
playlist.PlaylistEntries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
string text = new M3uContent().ToText(playlist);
|
string text = new M3uContent().ToText(playlist);
|
||||||
File.WriteAllText(playlistPath, text);
|
File.WriteAllText(playlistPath, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(".m3u8", extension, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(".m3u8", extension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var playlist = new M3uPlaylist();
|
var playlist = new M3uPlaylist();
|
||||||
|
@ -427,12 +433,14 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
{
|
{
|
||||||
entry.Duration = TimeSpan.FromTicks(child.RunTimeTicks.Value);
|
entry.Duration = TimeSpan.FromTicks(child.RunTimeTicks.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist.PlaylistEntries.Add(entry);
|
playlist.PlaylistEntries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
string text = new M3u8Content().ToText(playlist);
|
string text = new M3u8Content().ToText(playlist);
|
||||||
File.WriteAllText(playlistPath, text);
|
File.WriteAllText(playlistPath, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(".pls", extension, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(".pls", extension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var playlist = new PlsPlaylist();
|
var playlist = new PlsPlaylist();
|
||||||
|
@ -448,6 +456,7 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
{
|
{
|
||||||
entry.Length = TimeSpan.FromTicks(child.RunTimeTicks.Value);
|
entry.Length = TimeSpan.FromTicks(child.RunTimeTicks.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist.PlaylistEntries.Add(entry);
|
playlist.PlaylistEntries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,7 +482,7 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
throw new ArgumentException("File absolute path was null or empty.", nameof(fileAbsolutePath));
|
throw 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;
|
folderPath = folderPath + Path.DirectorySeparatorChar;
|
||||||
}
|
}
|
||||||
|
@ -481,7 +490,11 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
var folderUri = new Uri(folderPath);
|
var folderUri = new Uri(folderPath);
|
||||||
var fileAbsoluteUri = new Uri(fileAbsolutePath);
|
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);
|
var relativeUri = folderUri.MakeRelativeUri(fileAbsoluteUri);
|
||||||
string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
|
string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
|
||||||
|
|
|
@ -1006,8 +1006,8 @@ namespace MediaBrowser.Api.Library
|
||||||
public void Delete(DeleteItems request)
|
public void Delete(DeleteItems request)
|
||||||
{
|
{
|
||||||
var ids = string.IsNullOrWhiteSpace(request.Ids)
|
var ids = string.IsNullOrWhiteSpace(request.Ids)
|
||||||
? Array.Empty<string>()
|
? Array.Empty<string>()
|
||||||
: request.Ids.Split(',');
|
: request.Ids.Split(',');
|
||||||
|
|
||||||
foreach (var i in ids)
|
foreach (var i in ids)
|
||||||
{
|
{
|
||||||
|
@ -1028,7 +1028,6 @@ namespace MediaBrowser.Api.Library
|
||||||
_libraryManager.DeleteItem(item, new DeleteOptions
|
_libraryManager.DeleteItem(item, new DeleteOptions
|
||||||
{
|
{
|
||||||
DeleteFileLocation = true
|
DeleteFileLocation = true
|
||||||
|
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue