mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-15 10:43:30 +01:00
Fix playlists library and migration (#9770)
This commit is contained in:
@@ -67,9 +67,8 @@ namespace Emby.Server.Implementations.Playlists
|
||||
public async Task<PlaylistCreationResult> CreatePlaylist(PlaylistCreationRequest options)
|
||||
{
|
||||
var name = options.Name;
|
||||
|
||||
var folderName = _fileSystem.GetValidFilename(name);
|
||||
var parentFolder = GetPlaylistsFolder(Guid.Empty);
|
||||
var parentFolder = GetPlaylistsFolder(options.UserId);
|
||||
if (parentFolder is null)
|
||||
{
|
||||
throw new ArgumentException(nameof(parentFolder));
|
||||
@@ -80,7 +79,6 @@ namespace Emby.Server.Implementations.Playlists
|
||||
foreach (var itemId in options.ItemIdList)
|
||||
{
|
||||
var item = _libraryManager.GetItemById(itemId);
|
||||
|
||||
if (item is null)
|
||||
{
|
||||
throw new ArgumentException("No item exists with the supplied Id");
|
||||
@@ -121,7 +119,6 @@ namespace Emby.Server.Implementations.Playlists
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserById(options.UserId);
|
||||
|
||||
var path = Path.Combine(parentFolder.Path, folderName);
|
||||
path = GetTargetPath(path);
|
||||
|
||||
@@ -130,7 +127,6 @@ namespace Emby.Server.Implementations.Playlists
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
var playlist = new Playlist
|
||||
{
|
||||
Name = name,
|
||||
@@ -140,7 +136,6 @@ namespace Emby.Server.Implementations.Playlists
|
||||
};
|
||||
|
||||
playlist.SetMediaType(options.MediaType);
|
||||
|
||||
parentFolder.AddChild(playlist);
|
||||
|
||||
await playlist.RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(_fileSystem)) { ForceSave = true }, CancellationToken.None)
|
||||
@@ -326,7 +321,8 @@ namespace Emby.Server.Implementations.Playlists
|
||||
}
|
||||
}
|
||||
|
||||
private void SavePlaylistFile(Playlist item)
|
||||
/// <inheritdoc />
|
||||
public void SavePlaylistFile(Playlist item)
|
||||
{
|
||||
// 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
|
||||
@@ -564,20 +560,5 @@ namespace Emby.Server.Implementations.Playlists
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task UpdatePlaylistAsync(Playlist playlist)
|
||||
{
|
||||
var currentPlaylist = (Playlist)_libraryManager.GetItemById(playlist.Id);
|
||||
currentPlaylist.OwnerUserId = playlist.OwnerUserId;
|
||||
currentPlaylist.Shares = playlist.Shares;
|
||||
|
||||
await playlist.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
if (currentPlaylist.IsFile)
|
||||
{
|
||||
SavePlaylistFile(currentPlaylist);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user