Use a find instead of an each loop

This commit is contained in:
ChunkyProgrammer 2024-07-10 09:26:31 -04:00
parent 123c4dfba5
commit 77de46f316

View File

@ -291,10 +291,9 @@ struct Invidious::User
def from_newpipe(user : User, body : String) : Bool def from_newpipe(user : User, body : String) : Bool
Compress::Zip::File.open(IO::Memory.new(body), true) do |file| Compress::Zip::File.open(IO::Memory.new(body), true) do |file|
file.entries.each do |entry| entry = file.entries.find { |file_entry| file_entry.filename == "newpipe.db" }
return false if entry.nil?
entry.open do |file_io| entry.open do |file_io|
next if entry.filename != "newpipe.db"
# 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)
@ -327,7 +326,6 @@ struct Invidious::User
end end
end end
end end
end
# Success! # Success!
return true return true