From ff34b42e10dcc36cd0b7ccff11819afc62827e57 Mon Sep 17 00:00:00 2001 From: bohung Date: Thu, 4 Aug 2022 10:20:51 +0800 Subject: [PATCH] Fix bug for updating from older kernel. --- temp_file/app/helpers/admin/gmail_helper.rb | 15 ++++++++++----- temp_file/app/models/site.rb | 12 +++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/temp_file/app/helpers/admin/gmail_helper.rb b/temp_file/app/helpers/admin/gmail_helper.rb index 0becd2e..23b17af 100644 --- a/temp_file/app/helpers/admin/gmail_helper.rb +++ b/temp_file/app/helpers/admin/gmail_helper.rb @@ -8,10 +8,15 @@ module Admin::GmailHelper @secret = secret end end - - require "google/apis/gmail_v1" - require "googleauth" - require "googleauth/stores/file_token_store" + begin + require "google/apis/gmail_v1" + rescue LoadError => e + end + begin + require "googleauth" + require "googleauth/stores/file_token_store" + rescue LoadError => e + end require "fileutils" SCOPE = ['https://mail.google.com/'] OOB_URI = "urn:ietf:wg:oauth:2.0:oob" @@ -116,4 +121,4 @@ module Admin::GmailHelper service.send_user_message(user_id,message,quota_user: site[:title][site.default_locale||:zh_tw]){|r,err| result=r;error=err} [service,error] end -end +end \ No newline at end of file diff --git a/temp_file/app/models/site.rb b/temp_file/app/models/site.rb index 4bd8f8d..2068008 100644 --- a/temp_file/app/models/site.rb +++ b/temp_file/app/models/site.rb @@ -168,8 +168,10 @@ class Site end after_save do File.open("config/member_extra_db.txt","w+"){|f| f.write(self.member_extra_db)} - OrbitHelper::SharedHash['current_site']['site'] = self if @changed && OrbitHelper::SharedHash['current_site'] - OrbitHelper::SharedHash['privileged_page_count'].value = self.privileged_page_count + if (defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash rescue false) + OrbitHelper::SharedHash['current_site']['site'] = self if @changed && OrbitHelper::SharedHash['current_site'] + OrbitHelper::SharedHash['privileged_page_count'].value = self.privileged_page_count + end end after_initialize do |record| if !record.new_record? && !@skip_callback @@ -191,10 +193,10 @@ class Site end end def need_process_ip - OrbitHelper::SharedHash['privileged_page_count'].value != 0 + OrbitHelper::SharedHash['privileged_page_count'].value != 0 rescue false end def has_privileged_page - OrbitHelper::SharedHash['privileged_page_count'].value != 0 && self.privileged_ip_range.present? + (OrbitHelper::SharedHash['privileged_page_count'].value != 0 && self.privileged_ip_range.present? rescue false) end def check_ip_is_privileged?(ip, user=(user_nil=true; nil)) flag = (self.privileged_ip_range.blank?) @@ -309,4 +311,4 @@ class Site def min_memory return 50000 #50k bytes end -end +end \ No newline at end of file