mirror of
https://github.com/nishiki/manage-password.git
synced 2025-03-19 21:04:35 +00:00
secure the wallet config
This commit is contained in:
parent
684e0e32f0
commit
31751455c5
1 changed files with 11 additions and 3 deletions
|
@ -22,7 +22,7 @@ class MPW
|
||||||
|
|
||||||
# Read mpw file
|
# Read mpw file
|
||||||
def read_data
|
def read_data
|
||||||
@config = nil
|
@config = {}
|
||||||
@data = []
|
@data = []
|
||||||
@keys = {}
|
@keys = {}
|
||||||
@passwords = {}
|
@passwords = {}
|
||||||
|
@ -187,7 +187,15 @@ class MPW
|
||||||
# Set config
|
# Set config
|
||||||
# args: config -> a hash with config options
|
# args: config -> a hash with config options
|
||||||
def set_config(config)
|
def set_config(config)
|
||||||
@config = config
|
@config['sync'] = {} if @config['sync'].nil?
|
||||||
|
|
||||||
|
@config['sync']['type'] = config['sync']['type']
|
||||||
|
@config['sync']['host'] = config['sync']['host']
|
||||||
|
@config['sync']['port'] = config['sync']['port']
|
||||||
|
@config['sync']['user'] = config['sync']['user']
|
||||||
|
@config['sync']['password'] = config['sync']['password']
|
||||||
|
@config['sync']['path'] = config['sync']['path']
|
||||||
|
@config['sync']['last_sync'] = @config['sync']['last_sync'].nil? ? 0 : @config['sync']['last_sync']
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new item
|
# Add a new item
|
||||||
|
@ -300,7 +308,7 @@ class MPW
|
||||||
|
|
||||||
# Sync data with remote file
|
# Sync data with remote file
|
||||||
def sync
|
def sync
|
||||||
return if @config['sync'].nil?
|
return if @config.empty? or @config['sync'].nil?
|
||||||
|
|
||||||
tmp_file = "#{@wallet_file}.sync"
|
tmp_file = "#{@wallet_file}.sync"
|
||||||
last_sync = @config['last_sync'].to_i
|
last_sync = @config['last_sync'].to_i
|
||||||
|
|
Loading…
Add table
Reference in a new issue