Merge pull request #658 from TeamPiped/suppress-video-insert-conflict

Fix video update on conflict insert
This commit is contained in:
Kavin 2023-07-28 11:16:18 +01:00 committed by GitHub
commit 82aa66eee8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -159,8 +159,13 @@ public class VideoHelpers {
try (StatelessSession s = DatabaseSessionFactory.createStatelessSession()) {
var tr = s.beginTransaction();
try {
s.createNativeMutationQuery("INSERT INTO videos (uploader_id,duration,is_short,thumbnail,title,uploaded,views,id) values " +
"(:uploader_id,:duration,:is_short,:thumbnail,:title,:uploaded,:views,:id) ON CONFLICT DO NOTHING")
s.createNativeMutationQuery(
"INSERT INTO videos (uploader_id,duration,is_short,thumbnail,title,uploaded,views,id) values " +
"(:uploader_id,:duration,:is_short,:thumbnail,:title,:uploaded,:views,:id) ON CONFLICT (id) DO UPDATE SET " +
"duration = :duration," +
"title = :title," +
"views = :views"
)
.setParameter("uploader_id", video.getChannel())
.setParameter("duration", video.getDuration())
.setParameter("is_short", video.isShort())