Skip to content

The Free Software Media System - Server Backend & API

Merge branch 'master' into issue15137

Bond-00929582ed461b6
diff --cc Emby.Server.Implementations/Playlists/PlaylistManager.cs
index 4538fc6a3f,1577c5c9c7..409414139c
--- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs
+++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
@@@ -248,30 -243,9 +248,32 @@@ namespace Emby.Server.Implementations.P
}
// Update the playlist in the repository
- playlist.LinkedChildren = [.. playlist.LinkedChildren, .. childrenToAdd];
+ if (position.HasValue)
+ {
+ if (position.Value <= 0)
+ {
+ playlist.LinkedChildren = [.. childrenToAdd, .. playlist.LinkedChildren];
+ }
+ else if (position.Value >= playlist.LinkedChildren.Length)
+ {
+ playlist.LinkedChildren = [.. playlist.LinkedChildren, .. childrenToAdd];
+ }
+ else
+ {
+ playlist.LinkedChildren = [
+ .. playlist.LinkedChildren[0..position.Value],
+ .. childrenToAdd,
+ .. playlist.LinkedChildren[position.Value..playlist.LinkedChildren.Length]
+ ];
+ }
+ }
+ else
+ {
+ playlist.LinkedChildren = [.. playlist.LinkedChildren, .. childrenToAdd];
+ }
+
+ playlist.DateLastMediaAdded = DateTime.UtcNow;
+
await UpdatePlaylistInternal(playlist).ConfigureAwait(false);
// Refresh playlist metadata