mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-26 10:09:50 +05:30
Put temp.delete inside ensure block
This commit is contained in:
parent
6abee5de99
commit
6b0e4e6817
@ -298,30 +298,33 @@ struct Invidious::User
|
|||||||
# Ensure max size of 4MB
|
# Ensure max size of 4MB
|
||||||
io_sized = IO::Sized.new(file_io, 0x400000)
|
io_sized = IO::Sized.new(file_io, 0x400000)
|
||||||
|
|
||||||
temp = File.tempfile(".db") do |tempfile|
|
begin
|
||||||
begin
|
temp = File.tempfile(".db") do |tempfile|
|
||||||
File.write(tempfile.path, io_sized.gets_to_end)
|
begin
|
||||||
rescue
|
File.write(tempfile.path, io_sized.gets_to_end)
|
||||||
return false
|
rescue
|
||||||
end
|
return false
|
||||||
|
end
|
||||||
DB.open("sqlite3://" + tempfile.path) do |db|
|
|
||||||
user.watched += db.query_all("SELECT url FROM streams", as: String)
|
DB.open("sqlite3://" + tempfile.path) do |db|
|
||||||
.map(&.lchop("https://www.youtube.com/watch?v="))
|
user.watched += db.query_all("SELECT url FROM streams", as: String)
|
||||||
|
.map(&.lchop("https://www.youtube.com/watch?v="))
|
||||||
user.watched.uniq!
|
|
||||||
Invidious::Database::Users.update_watch_history(user)
|
user.watched.uniq!
|
||||||
|
Invidious::Database::Users.update_watch_history(user)
|
||||||
user.subscriptions += db.query_all("SELECT url FROM subscriptions", as: String)
|
|
||||||
.map(&.lchop("https://www.youtube.com/channel/"))
|
user.subscriptions += db.query_all("SELECT url FROM subscriptions", as: String)
|
||||||
|
.map(&.lchop("https://www.youtube.com/channel/"))
|
||||||
user.subscriptions.uniq!
|
|
||||||
user.subscriptions = get_batch_channels(user.subscriptions)
|
user.subscriptions.uniq!
|
||||||
|
user.subscriptions = get_batch_channels(user.subscriptions)
|
||||||
Invidious::Database::Users.update_subscriptions(user)
|
|
||||||
|
Invidious::Database::Users.update_subscriptions(user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
temp.delete if !temp.nil?
|
||||||
end
|
end
|
||||||
temp.delete
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user