summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2016-01-17 15:43:04 +0100
committerChris Schlaeger <chris@linux.com>2016-01-17 15:43:04 +0100
commitf3108e6147f92bf8f063b6681bd28eae6ced823a (patch)
tree4e98d8f87e5088e4983767a8ae4648f18ca01f6a /lib
parented1d5cde7f92d9d7c7de28aa4b516da3e0baf8e5 (diff)
downloadpostrunner-f3108e6147f92bf8f063b6681bd28eae6ced823a.zip
Don't crash on partially migrated DB.
Diffstat (limited to 'lib')
-rw-r--r--lib/postrunner/Main.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/postrunner/Main.rb b/lib/postrunner/Main.rb
index 75af05b..0af9a09 100644
--- a/lib/postrunner/Main.rb
+++ b/lib/postrunner/Main.rb
@@ -47,13 +47,16 @@ module PostRunner
end
# Create a hash to store configuration data in the store unless it
# exists already.
- unless @db['config']
+ unless (cfg = @db['config'])
@db['config'] = @db.new(PEROBS::Hash)
- @db['config']['unit_system'] = :metric
- @db['config']['html_dir'] = File.join(@db_dir, 'html')
- @db['config']['version'] = VERSION
end
- @db['config']['data_dir'] = @db_dir
+ cfg['unit_system'] = :metric unless cfg['unit_system']
+ cfg['html_dir'] = File.join(@db_dir, 'html') unless cfg['html_dir']
+ cfg['version'] = VERSION unless cfg['version']
+ # We always override the data_dir as the user might have moved the data
+ # directory. The only reason we store it in the DB is to have it
+ # available throught the application.
+ cfg['data_dir'] = @db_dir
setup_directories
execute_command(args)