Fix unintelligible error when importing empty file

IO#read returns nil for an empty file if given a length argument, which
caused a stack trace when attempting to import a file instead of a
useful error message.
unstable
James Lee 2013-05-07 18:05:45 -05:00
parent 9e7885857c
commit 9ab68ac935
1 changed files with 3 additions and 0 deletions

View File

@ -2797,6 +2797,9 @@ class DBManager
::File.open(filename, 'rb') do |f|
data = f.read(4)
end
if data.nil?
raise DBImportError.new("Zero-length file")
end
case data[0,4]
when "PK\x03\x04"