From f3108e6147f92bf8f063b6681bd28eae6ced823a Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Sun, 17 Jan 2016 15:43:04 +0100 Subject: Don't crash on partially migrated DB. --- lib/postrunner/Main.rb | 13 ++++++++----- 1 file 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) -- cgit v1.2.3