small fix for index file check

This commit is contained in:
Harry Bomrah 2017-07-05 11:49:43 +08:00
parent 4e48166bc6
commit db464d16f3
1 changed files with 5 additions and 2 deletions

View File

@ -109,11 +109,14 @@ class Admin::HpsLearningsController < OrbitAdminController
Zip::ZipFile.open(path) { |zip_file| Zip::ZipFile.open(path) { |zip_file|
zip_file.each { |f| zip_file.each { |f|
f_path=File.join(destination, f.name) f_path=File.join(destination, f.name)
zip_file.extract(f, f_path) unless File.exist?(f_path)
files << f.name files << f.name
zip_file.extract(f, f_path) unless File.exist?(f_path)
} }
} }
if files.include?("index.html") foldername = File.basename(path).split(".")
foldername.pop
foldername = foldername.join(".")
if files.include?(foldername + "/index.html")
render :json => {"success" => true}.to_json render :json => {"success" => true}.to_json
else else
render :json => {"success" => false, "msg" => "index.html file not present."}.to_json render :json => {"success" => false, "msg" => "index.html file not present."}.to_json