From bb00c2e77ff4186651c46d8c302225d1f9d442be Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Wed, 26 Feb 2020 17:24:16 +0000 Subject: [PATCH] Close zip file after listing entries to prevent leaking --- src/library.cr | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/library.cr b/src/library.cr index ad17475..e5d06ec 100644 --- a/src/library.cr +++ b/src/library.cr @@ -20,12 +20,14 @@ class Entry @zip_path = path @title = File.basename path, File.extname path @size = (File.size path).humanize_bytes - @pages = Zip::File.new(path).entries + file = Zip::File.new path + @pages = file.entries .select { |e| ["image/jpeg", "image/png"].includes? \ MIME.from_filename? e.filename } .size + file.close @cover_url = "/api/page/#{@book_title}/#{title}/1" @mtime = File.info(@zip_path).modification_time end