lib/veewee/provider/core/helper/iso.rb in veewee-0.3.0.alpha8 vs lib/veewee/provider/core/helper/iso.rb in veewee-0.3.0.alpha9
- old
+ new
@@ -35,11 +35,11 @@
end
},
:progress_proc => lambda {|s|
pbar.set s if pbar
}) { |src|
- # We assume large 10K files, so this is tempfile object
+ # We assume large 10K files, so this is tempfile object
env.logger.info "#{src.class}"
ui.info "Moving #{src.path} to #{localfile}"
# Force the close of the src stream to release handle before moving
# Not forcing the close may cause an issue on windows (Permission Denied)
src.close
@@ -63,11 +63,22 @@
end
end
return checksum.hexdigest
end
+ def verify_md5sum(full_path)
+ filename = File.basename(full_path)
+ ui.info "Verifying md5 checksum : #{self.iso_md5}"
+ file_md5=hashsum(full_path)
+ unless file_md5==self.iso_md5
+ ui.error "The MD5 checksums for file #{filename } do not match: "
+ ui.error "- #{file_md5} (current) vs #{self.iso_md5} (specified)"
+ raise Veewee::Error, "The MD5 checksums for file #{filename } do not match: \n"+ "- #{file_md5} (current) vs #{self.iso_md5} (specified)"
+ end
+ end
+
def verify_iso(options)
filename=self.iso_file
full_path=File.join(env.config.veewee.iso_dir,filename)
if File.exists?(full_path)
@@ -121,21 +132,14 @@
unless File.readable?(full_path)
raise Veewee::Error, "The provided iso #{full_path} is not readable"
end
- ui.info "Verifying md5 checksum : #{self.iso_md5}"
- file_md5=hashsum(full_path)
-
- unless file_md5==self.iso_md5
- ui.error "The MD5 checksums for file #{filename } do not match: "
- ui.error "- #{file_md5} (current) vs #{self.iso_md5} (specified)"
- raise Veewee::Error, "The MD5 checksums for file #{filename } do not match: \n"+ "- #{file_md5} (current) vs #{self.iso_md5} (specified)"
- end
-
end
end
+
+ verify_md5sum(full_path) if options["md5check"] && !self.iso_md5.nil?
end
end #Module
end #Module