mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-20 01:50:04 +00:00
fix sync
This commit is contained in:
parent
68062fe728
commit
59f9a5d40f
1 changed files with 20 additions and 4 deletions
24
lib/Sync.rb
24
lib/Sync.rb
|
@ -34,7 +34,7 @@ module MPW
|
||||||
@sync = SyncSSH.new(@config.sync_host, @config.sync_user, @config.sync_pwd, @config.sync_path, @config.sync_port)
|
@sync = SyncSSH.new(@config.sync_host, @config.sync_user, @config.sync_pwd, @config.sync_path, @config.sync_port)
|
||||||
when 'ftp'
|
when 'ftp'
|
||||||
require "#{APP_ROOT}/lib/Sync/FTP"
|
require "#{APP_ROOT}/lib/Sync/FTP"
|
||||||
@sync = SyncFTP.new
|
@sync = SyncFTP.new(@config.sync_host, @config.sync_user, @config.sync_pwd, @config.sync_path, @config.sync_port)
|
||||||
else
|
else
|
||||||
@error_msg = I18n.t('error.unknown_type')
|
@error_msg = I18n.t('error.unknown_type')
|
||||||
return false
|
return false
|
||||||
|
@ -74,11 +74,19 @@ module MPW
|
||||||
@remote.list.each do |r|
|
@remote.list.each do |r|
|
||||||
if item.id == r.id
|
if item.id == r.id
|
||||||
if item.last_edit < r.last_edit
|
if item.last_edit < r.last_edit
|
||||||
raise item.error_msg if not item.update(r.name, r.group, r.host, r.protocol, r.user, r.password, r.port, r.comment)
|
raise item.error_msg if not item.update(name: r.name,
|
||||||
|
group: r.group,
|
||||||
|
host: r.host,
|
||||||
|
protocol: r.protocol,
|
||||||
|
user: r.user,
|
||||||
|
password: r.password,
|
||||||
|
port: r.port,
|
||||||
|
comment: r.comment
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
update = true
|
update = true
|
||||||
data_remote.delete(j)
|
item.delete
|
||||||
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -96,7 +104,15 @@ module MPW
|
||||||
# Add item
|
# Add item
|
||||||
@remote.list.each do |r|
|
@remote.list.each do |r|
|
||||||
if r.last_edit > @config.last_update
|
if r.last_edit > @config.last_update
|
||||||
item = Item.new(r.name, r.group, r.host, r.protocol, r.user, r.password, r.port, r.comment)
|
item = Item.new(name: r.name,
|
||||||
|
group: r.group,
|
||||||
|
host: r.host,
|
||||||
|
protocol: r.protocol,
|
||||||
|
user: r.user,
|
||||||
|
password: r.password,
|
||||||
|
port: r.port,
|
||||||
|
comment: r.comment
|
||||||
|
)
|
||||||
raise @local.error_msg if not @local.add(item)
|
raise @local.error_msg if not @local.add(item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue