mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-23 13:57:52 +00:00
fix bug when the MPW server haven't data
This commit is contained in:
parent
7305ecef0f
commit
0739be1763
2 changed files with 9 additions and 6 deletions
|
@ -273,6 +273,8 @@ module MPW
|
|||
def sync(data_remote, last_update)
|
||||
if !data_remote.instance_of?(Array)
|
||||
return false
|
||||
else data_remote.nil? || data_remote.empty?
|
||||
return true
|
||||
end
|
||||
|
||||
@data.each do |l|
|
||||
|
|
|
@ -67,9 +67,14 @@ module MPW
|
|||
end
|
||||
|
||||
if !defined?(msg['error'])
|
||||
error_msg = I18n.t('error.sync.communication')
|
||||
@error_msg = I18n.t('error.sync.communication')
|
||||
return nil
|
||||
elsif msg['error'].nil?
|
||||
elsif !msg['error'].nil?
|
||||
@error_msg = I18n.t(msg['error'])
|
||||
return nil
|
||||
elsif msg['data'].nil? || msg['data'].empty?
|
||||
return []
|
||||
else
|
||||
tmp_file = tmpfile
|
||||
File.open(tmp_file, 'w') do |file|
|
||||
file << msg['data']
|
||||
|
@ -83,11 +88,7 @@ module MPW
|
|||
|
||||
File.unlink(tmp_file)
|
||||
return mpw.search
|
||||
else
|
||||
@error_msg = I18n.t(msg['error'])
|
||||
return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Update the remote data
|
||||
|
|
Loading…
Reference in a new issue