completing the code with segment fault

This commit is contained in:
Kaito 2011-08-16 12:14:01 +08:00
parent 8895b9fe20
commit d75dd4f936
2 changed files with 9 additions and 11 deletions

View File

@ -27,13 +27,10 @@ class Admin::DesignsController < ApplicationController
Zip::ZipFile.open(file) { |zip_file| Zip::ZipFile.open(file) { |zip_file|
design = Design.new.from_json(zip_file.read("#{zip_name}/info.json")) design = Design.new.from_json(zip_file.read("#{zip_name}/info.json"))
Dir.mktmpdir('f_path') { |dir| Dir.mktmpdir('f_path') { |dir|
#layout_entry =""
#struct_css_entry =""
design.build_layout design.build_layout
themes_entries = [] themes_entries = []
javascripts_entries = [] javascripts_entries = []
images_entries = [] images_entries = []
debugger
temp_file4layout = File.new(dir + '/' + zip_name+'-1', 'w+') temp_file4layout = File.new(dir + '/' + zip_name+'-1', 'w+')
temp_file4layout.binmode temp_file4layout.binmode
#dir/zip_name #dir/zip_name
@ -60,21 +57,22 @@ class Admin::DesignsController < ApplicationController
images_entries << entry images_entries << entry
end end
end end
debugger
['themes', 'javascripts', 'images'].each do |type| ['themes', 'javascripts', 'images'].each do |type|
eval("#{type}_entries").each do |entry|
#incompleted #incompleted
eval("#{type}.entries").each do |entry| filename = File.basename entry.to_s
title = File.basename entry temp_file = File.new(dir + '/' + filename, 'w+')
debugger temp_file.binmode
temp_file = File.new(dir + '/' + title+'-3', 'w+')
temp_file.write zip_file.read entry temp_file.write zip_file.read entry
object.file = temp_file build_and_store = eval("design.#{type}").build
object.to_save = true build_and_store.file = temp_file
build_and_store.file_filename = filename
build_and_store._type = (File.extname entry.to_s).delete '.'
build_and_store.to_save = true
end end
end end
} }
design.save design.save
} }
end end