Fixes a db_import bug introduced in r11355 .
git-svn-id: file:///home/svn/framework3/trunk@11416 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
37a3ca4643
commit
0468dbeabe
|
@ -1965,11 +1965,7 @@ class DBManager
|
||||||
# If there is no match, an error is raised instead.
|
# If there is no match, an error is raised instead.
|
||||||
def import_filetype_detect(data)
|
def import_filetype_detect(data)
|
||||||
|
|
||||||
if not (data and data.length > 0)
|
if data and data.kind_of? Zip::ZipFile
|
||||||
raise DBImportError.new("The data provided to the import function was empty")
|
|
||||||
end
|
|
||||||
|
|
||||||
if data.kind_of? Zip::ZipFile
|
|
||||||
raise DBImportError.new("The zip file provided is empty.") if data.entries.empty?
|
raise DBImportError.new("The zip file provided is empty.") if data.entries.empty?
|
||||||
@import_filedata ||= {}
|
@import_filedata ||= {}
|
||||||
@import_filedata[:zip_filename] = File.split(data.to_s).last
|
@import_filedata[:zip_filename] = File.split(data.to_s).last
|
||||||
|
@ -1985,7 +1981,7 @@ class DBManager
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.kind_of? PacketFu::PcapFile
|
if data and data.kind_of? PacketFu::PcapFile
|
||||||
raise DBImportError.new("The pcap file provided is empty.") if data.body.empty?
|
raise DBImportError.new("The pcap file provided is empty.") if data.body.empty?
|
||||||
@import_filedata ||= {}
|
@import_filedata ||= {}
|
||||||
@import_filedata[:type] = "Libpcap Packet Capture"
|
@import_filedata[:type] = "Libpcap Packet Capture"
|
||||||
|
@ -1993,6 +1989,10 @@ class DBManager
|
||||||
end
|
end
|
||||||
|
|
||||||
# Text string kinds of data.
|
# Text string kinds of data.
|
||||||
|
if data and data.to_s.strip.size.zero?
|
||||||
|
raise DBImportError.new("The data provided to the import function was empty")
|
||||||
|
end
|
||||||
|
|
||||||
di = data.index("\n")
|
di = data.index("\n")
|
||||||
firstline = data[0, di]
|
firstline = data[0, di]
|
||||||
@import_filedata ||= {}
|
@import_filedata ||= {}
|
||||||
|
|
Loading…
Reference in New Issue