diff --git a/MPW/MPW.rb b/MPW/MPW.rb index 05da9cf..71e6f3d 100644 --- a/MPW/MPW.rb +++ b/MPW/MPW.rb @@ -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| diff --git a/MPW/Sync/MPWSync.rb b/MPW/Sync/MPWSync.rb index da62975..8e6c700 100644 --- a/MPW/Sync/MPWSync.rb +++ b/MPW/Sync/MPWSync.rb @@ -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