Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Commit dc3bbd1

Browse files
committed
Close zip file after listing entries to prevent leaking
1 parent c89c74c commit dc3bbd1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/library.cr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ class Entry
2525
@title = File.basename path, File.extname path
2626
@encoded_title = URI.encode @title
2727
@size = (File.size path).humanize_bytes
28-
@pages = Zip::File.new(path).entries
28+
file = Zip::File.new path
29+
@pages = file.entries
2930
.select { |e|
3031
["image/jpeg", "image/png"].includes? \
3132
MIME.from_filename? e.filename
3233
}
3334
.size
35+
file.close
3436
@id = storage.get_id @zip_path, false
3537
@cover_url = "/api/page/#{@title_id}/#{@id}/1"
3638
@mtime = File.info(@zip_path).modification_time

0 commit comments

Comments
 (0)