From 5676881ec1348faca5b92d3b014ee43c73b90ede Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 1 May 2023 00:57:28 +0100 Subject: [PATCH] Fix missing transaction when trying to insert new videos in a playlist --- .../server/handlers/auth/AuthPlaylistHandlers.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/kavin/piped/server/handlers/auth/AuthPlaylistHandlers.java b/src/main/java/me/kavin/piped/server/handlers/auth/AuthPlaylistHandlers.java index f1c6105..05b1ff4 100644 --- a/src/main/java/me/kavin/piped/server/handlers/auth/AuthPlaylistHandlers.java +++ b/src/main/java/me/kavin/piped/server/handlers/auth/AuthPlaylistHandlers.java @@ -255,7 +255,15 @@ public class AuthPlaylistHandlers { video = new PlaylistVideo(videoId, info.getName(), info.getThumbnailUrl(), info.getDuration(), channel); - s.persist(video); + var tr = s.beginTransaction(); + try { + s.persist(video); + tr.commit(); + } catch (Exception e) { + tr.rollback(); + ExceptionHandler.handle(e); + continue; + } } catch (Exception e) { ExceptionHandler.handle(e); continue;