1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-27 07:33:05 +00:00

fix bug when the MPW server haven't data

This commit is contained in:
nishiki 2014-04-27 15:17:37 +02:00
parent 7305ecef0f
commit 0739be1763
2 changed files with 9 additions and 6 deletions

View file

@ -273,6 +273,8 @@ module MPW
def sync(data_remote, last_update) def sync(data_remote, last_update)
if !data_remote.instance_of?(Array) if !data_remote.instance_of?(Array)
return false return false
else data_remote.nil? || data_remote.empty?
return true
end end
@data.each do |l| @data.each do |l|

View file

@ -67,9 +67,14 @@ module MPW
end end
if !defined?(msg['error']) if !defined?(msg['error'])
error_msg = I18n.t('error.sync.communication') @error_msg = I18n.t('error.sync.communication')
return nil 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 tmp_file = tmpfile
File.open(tmp_file, 'w') do |file| File.open(tmp_file, 'w') do |file|
file << msg['data'] file << msg['data']
@ -83,11 +88,7 @@ module MPW
File.unlink(tmp_file) File.unlink(tmp_file)
return mpw.search return mpw.search
else
@error_msg = I18n.t(msg['error'])
return nil
end end
end end
# Update the remote data # Update the remote data