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:
parent
0739be1763
commit
fe973c2fac
1 changed files with 20 additions and 22 deletions
42
MPW/MPW.rb
42
MPW/MPW.rb
|
@ -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|
|
|
||||||
j = 0
|
# Update item
|
||||||
update = false
|
data_remote.each do |r|
|
||||||
|
if l[ID] == r[ID]
|
||||||
# Update item
|
if l[DATE].to_i < r[DATE].to_i
|
||||||
data_remote.each do |r|
|
update(r[NAME], r[GROUP], r[SERVER], r[PROTOCOL], r[LOGIN], r[PASSWORD], r[PORT], r[COMMENT], l[ID])
|
||||||
if l[ID] == r[ID]
|
end
|
||||||
if l[DATE].to_i < r[DATE].to_i
|
update = true
|
||||||
update(r[NAME], r[GROUP], r[SERVER], r[PROTOCOL], r[LOGIN], r[PASSWORD], r[PORT], r[COMMENT], l[ID])
|
data_remote.delete_at(j)
|
||||||
|
break
|
||||||
end
|
end
|
||||||
update = true
|
j += 1
|
||||||
data_remote.delete_at(j)
|
end
|
||||||
break
|
|
||||||
|
# Delete an old item
|
||||||
|
if !update && l[DATE].to_i < last_update
|
||||||
|
remove(l[ID])
|
||||||
end
|
end
|
||||||
j += 1
|
|
||||||
end
|
|
||||||
|
|
||||||
# Delete an old item
|
|
||||||
if !update && l[DATE].to_i < last_update
|
|
||||||
remove(l[ID])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue