summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-03-28 23:05:20 -0500
committerOmar Roth <omarroth@hotmail.com>2018-03-28 23:05:20 -0500
commit10f2048d957ce41caee444859e45bb71d5f84148 (patch)
tree305f89e71d10f8dcb5951edec8a474ec8b31d1d1
parent239a6c892cf58a0d85184f5eda05437743b8c8b7 (diff)
downloadinvidious-10f2048d957ce41caee444859e45bb71d5f84148.tar.gz
invidious-10f2048d957ce41caee444859e45bb71d5f84148.tar.bz2
invidious-10f2048d957ce41caee444859e45bb71d5f84148.zip
Add conflict resolution for channel updates
-rw-r--r--src/helpers.cr5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/helpers.cr b/src/helpers.cr
index 08473de9..a26bb310 100644
--- a/src/helpers.cr
+++ b/src/helpers.cr
@@ -502,10 +502,11 @@ def get_channel(id, client, db)
if Time.now - channel.updated > 1.minutes
channel = fetch_channel(id, client, db)
- channel_array = channel.to_a[1..-1]
+ channel_array = channel.to_a
args = arg_array(channel_array)
- db.exec("UPDATE channels SET (author,updated) = (#{args}) WHERE id = '#{channel.id}'", channel_array)
+ db.exec("INSERT INTO channels VALUES (#{args}) \
+ ON CONFLICT (id) DO UPDATE SET author = $2, updated = $3", channel_array)
end
else
channel = fetch_channel(id, client, db)