Properly close archive files after validating them

This commit is contained in:
Alex Ling 2020-07-11 15:51:57 +00:00
parent 07100121ef
commit 2208f90d8e

View File

@ -95,12 +95,16 @@ def compare_alphanumerically(a : String, b : String)
end end
def validate_archive(path : String) : Exception? def validate_archive(path : String) : Exception?
file = nil
begin
file = ArchiveFile.new path file = ArchiveFile.new path
file.check file.check
file.close file.close
return return
rescue e rescue e
file.close unless file.nil?
e e
end
end end
def random_str def random_str