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

fix bug sync when the gpg file doesn't exist

This commit is contained in:
nishiki 2014-04-27 18:10:21 +02:00
parent 0739be1763
commit fe973c2fac

View file

@ -273,30 +273,28 @@ 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? else !data_remote.nil? && !data_remote.empty?
return true @data.each do |l|
end j = 0
update = false
@data.each do |l| # Update item
j = 0 data_remote.each do |r|
update = false if l[ID] == r[ID]
if l[DATE].to_i < r[DATE].to_i
# Update item update(r[NAME], r[GROUP], r[SERVER], r[PROTOCOL], r[LOGIN], r[PASSWORD], r[PORT], r[COMMENT], l[ID])
data_remote.each do |r| end
if l[ID] == r[ID] update = true
if l[DATE].to_i < r[DATE].to_i data_remote.delete_at(j)
update(r[NAME], r[GROUP], r[SERVER], r[PROTOCOL], r[LOGIN], r[PASSWORD], r[PORT], r[COMMENT], l[ID]) break
end end
update = true j += 1
data_remote.delete_at(j)
break
end end
j += 1
end
# Delete an old item # Delete an old item
if !update && l[DATE].to_i < last_update if !update && l[DATE].to_i < last_update
remove(l[ID]) remove(l[ID])
end
end end
end end