Fix bug for updating from older kernel.

This commit is contained in:
BoHung Chiu 2022-08-04 10:20:51 +08:00
parent 7023990086
commit ff34b42e10
2 changed files with 17 additions and 10 deletions

View File

@ -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

View File

@ -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