From 01c31518b0c4866a4715b3235f50b722ff8dd86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Sat, 8 Apr 2023 23:12:29 +0800 Subject: [PATCH] fix error --- app/helpers/announcements_helper.rb | 8 ++++---- temp_file/Gemfile | 9 ++++++--- temp_file/app/controllers/admin/playground_controller.rb | 2 +- temp_file/app/helpers/orbit_helper.rb | 4 ++-- temp_file/config/unicorn.rb | 6 +++--- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/helpers/announcements_helper.rb b/app/helpers/announcements_helper.rb index 8e126ed..3002ced 100644 --- a/app/helpers/announcements_helper.rb +++ b/app/helpers/announcements_helper.rb @@ -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 "
Maybe the administrator has changed the theme, please select the index page design again from the page settings.
".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"] || [] diff --git a/temp_file/Gemfile b/temp_file/Gemfile index dc3f235..ac16fb1 100644 --- a/temp_file/Gemfile +++ b/temp_file/Gemfile @@ -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' diff --git a/temp_file/app/controllers/admin/playground_controller.rb b/temp_file/app/controllers/admin/playground_controller.rb index bc4f50d..682e80d 100644 --- a/temp_file/app/controllers/admin/playground_controller.rb +++ b/temp_file/app/controllers/admin/playground_controller.rb @@ -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? diff --git a/temp_file/app/helpers/orbit_helper.rb b/temp_file/app/helpers/orbit_helper.rb index 976e03f..c7605fc 100644 --- a/temp_file/app/helpers/orbit_helper.rb +++ b/temp_file/app/helpers/orbit_helper.rb @@ -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] diff --git a/temp_file/config/unicorn.rb b/temp_file/config/unicorn.rb index f35156e..7b5ec83 100644 --- a/temp_file/config/unicorn.rb +++ b/temp_file/config/unicorn.rb @@ -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