fix error

This commit is contained in:
邱博亞 2023-04-08 23:12:29 +08:00
parent 97e19c232e
commit 01c31518b0
5 changed files with 16 additions and 13 deletions

View File

@ -294,9 +294,9 @@ module AnnouncementsHelper
if @target_action == "index"
filename = File.basename(overridehtml.nil? ? params[:layout_type] : overridehtml)
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'announcement', "#{filename}.html.erb")
if !File.exists?f
if !File.exist?f
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'announcement', "index.html.erb")
if !File.exists?f
if !File.exist?f
return "<div class='well'>Maybe the administrator has changed the theme, please select the index page design again from the page settings.</div>".html_safe
end
end
@ -336,7 +336,7 @@ module AnnouncementsHelper
else
filename = overridehtml.nil? ? @target_action : overridehtml
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'announcement', "#{filename}.html.erb")
if File.exists?f
if File.exist?f
file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close
@ -438,7 +438,7 @@ module AnnouncementsHelper
layout_types = []
@key = Site.first.template
f = File.join("#{Rails.root}/app/templates/#{@key}/modules/#{module_app}/info.json")
if File.exists?f
if File.exist?f
info = File.read(f)
hash = JSON.parse(info) rescue {}
frontends = hash["frontend"] || []

View File

@ -49,7 +49,7 @@ unless File.exist?(File.dirname(__FILE__) + '/downloaded_extensions.rb')
File.open(File.dirname(__FILE__) + '/downloaded_extensions.rb','w+'){|f| f.write ""}
end
eval(File.read(File.dirname(__FILE__) + '/downloaded_extensions.rb'))
if File.exists?(File.dirname(__FILE__) + '/extra_gems.rb')
if File.exist?(File.dirname(__FILE__) + '/extra_gems.rb')
eval(File.read(File.dirname(__FILE__) + '/extra_gems.rb'))
end
#ask
@ -63,9 +63,9 @@ gem 'payment_settup',git: 'http://gitlab.tp.rulingcom.com/chiu/payment_settup.gi
# gem 'angularjs-rails', '~> 1.2.20'
# gem 'angular-ui-bootstrap-rails', '~> 0.11.0'
# gem 'jquery_mousewheel_rails', '~> 3.1.11.3'
gem 'process_shared','~>0.2.1'
gem 'faraday', '0.15.4'
gem 'process_shared', git: 'http://gitlab.tp.rulingcom.com/core/process_shared'
if RUBY_VERSION.to_f == 2.1
gem 'faraday', '0.15.4'
gem 'declarative','0.0.10'
gem 'mime-types','~>3.3.1'
gem 'mimemagic','0.3.9'
@ -155,6 +155,9 @@ if RUBY_VERSION.to_f == 2.1
gem 'minitest-spec-rails'
end
else
gem 'sorted_set'
gem 'faraday'
gem 'ffi', '1.14.2'
gem 'declarative'
gem 'mime-types'
gem 'mimemagic'

View File

@ -113,7 +113,7 @@ class Admin::PlaygroundController < OrbitAdminController
if params[:type] == "restart"
render :json => {"success" => true}.to_json
file = File.join(Rails.root,"tmp","restart_unicorn.sh")
File.delete(file) if File.exists?(file)
File.delete(file) if File.exist?(file)
else
mul = Multithread.where(key: 'playground').first
if !mul.nil?

View File

@ -503,7 +503,7 @@ module OrbitHelper
temp_ids = []
feeds.each do |feed|
file = File.join(Rails.root,"public","site_feeds",feed.id.to_s,feed.feed_uid.to_s + ".json")
if File.exists?(file)
if File.exist?(file)
d = File.read(file)
d = JSON.parse(d) rescue {ma.key.pluralize => []}
cat = Category.find(feed.merge_with_category).title
@ -537,7 +537,7 @@ module OrbitHelper
feed = SiteFeed.find(feed_id) rescue nil
if !feed.nil?
file = File.join(Rails.root,"public","site_feeds",feed.id.to_s,feed.feed_uid.to_s + ".json")
if File.exists?(file)
if File.exist?(file)
d = File.read(file)
d = JSON.parse(d)
objects = d[@module_app.key.pluralize]

View File

@ -6,11 +6,11 @@ rails_env = ENV['RAILS_ENV'] || 'production'
cpu_cores = %x(cat /proc/cpuinfo | grep processor | wc -l).sub("\n",'').to_i * 3 / 4 rescue 2
default_cpu_cores = cpu_cores
if File.exists?("#{rails_root}/cpu_cores.txt")
if File.exist?("#{rails_root}/cpu_cores.txt")
cpu_cores = File.read("#{rails_root}/cpu_cores.txt").force_encoding('utf-8').sub("\n",'').to_i rescue default_cpu_cores
else
begin
cpu_cores = File.read("#{rails_root}/../cpu_cores.txt").force_encoding('utf-8').sub("\n",'').to_i if (File.exists?("#{rails_root}/../cpu_cores.txt") rescue false)
cpu_cores = File.read("#{rails_root}/../cpu_cores.txt").force_encoding('utf-8').sub("\n",'').to_i if (File.exist?("#{rails_root}/../cpu_cores.txt") rescue false)
rescue => e
cpu_cores = default_cpu_cores
end
@ -29,7 +29,7 @@ stdout_path "#{rails_root}/log/unicorn.log"
before_fork do |server, worker|
ENV['worker_num'] = "#{worker.nr}"
old_pid = "#{rails_root}/tmp/pids/unicorn.pid.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
if File.exist?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH