aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Playlists/PlaylistManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Playlists/PlaylistManager.cs')
-rw-r--r--Emby.Server.Implementations/Playlists/PlaylistManager.cs18
1 files changed, 15 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
index 7b0a16441..1ce363de5 100644
--- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs
+++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
@@ -134,14 +134,16 @@ namespace Emby.Server.Implementations.Playlists
try
{
- Directory.CreateDirectory(path);
+ var info = Directory.CreateDirectory(path);
var playlist = new Playlist
{
Name = name,
Path = path,
OwnerUserId = request.UserId,
Shares = request.Users ?? [],
- OpenAccess = request.Public ?? false
+ OpenAccess = request.Public ?? false,
+ DateCreated = info.CreationTimeUtc,
+ DateModified = info.LastWriteTimeUtc
};
playlist.SetMediaType(request.MediaType);
@@ -283,6 +285,16 @@ namespace Emby.Server.Implementations.Playlists
RefreshPriority.High);
}
+ internal static int DetermineAdjustedIndex(int newPriorIndexAllChildren, int newIndex)
+ {
+ if (newIndex == 0)
+ {
+ return newPriorIndexAllChildren > 0 ? newPriorIndexAllChildren - 1 : 0;
+ }
+
+ return newPriorIndexAllChildren + 1;
+ }
+
public async Task MoveItemAsync(string playlistId, string entryId, int newIndex, Guid callingUserId)
{
if (_libraryManager.GetItemById(playlistId) is not Playlist playlist)
@@ -305,7 +317,7 @@ namespace Emby.Server.Implementations.Playlists
var newPriorItemIndex = newIndex > oldIndexAccessible ? newIndex : newIndex - 1 < 0 ? 0 : newIndex - 1;
var newPriorItemId = accessibleChildren[newPriorItemIndex].Item1.ItemId;
var newPriorItemIndexOnAllChildren = children.FindIndex(c => c.Item1.ItemId.Equals(newPriorItemId));
- var adjustedNewIndex = newPriorItemIndexOnAllChildren + 1;
+ var adjustedNewIndex = DetermineAdjustedIndex(newPriorItemIndexOnAllChildren, newIndex);
var item = playlist.LinkedChildren.FirstOrDefault(i => string.Equals(entryId, i.ItemId?.ToString("N", CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase));
if (item is null)