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