From 05d27c64bebe0f4d8e4c0d437a6a27884633f372 Mon Sep 17 00:00:00 2001 From: g0tmi1k Date: Fri, 11 May 2018 11:21:14 +0100 Subject: [PATCH] Check location before using them --- lib/common/cache_file_store.rb | 4 ++++ lib/common/db_updater.rb | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/common/cache_file_store.rb b/lib/common/cache_file_store.rb index 09af0714..98c0f331 100644 --- a/lib/common/cache_file_store.rb +++ b/lib/common/cache_file_store.rb @@ -26,6 +26,10 @@ class CacheFileStore unless Dir.exist?(@storage_path) FileUtils.mkdir_p(@storage_path) end + + unless Pathname.new(@storage_path).writable? + fail "#{@storage_path} is not writable" + end end def clean diff --git a/lib/common/db_updater.rb b/lib/common/db_updater.rb index eb833ac6..c2e1a5eb 100644 --- a/lib/common/db_updater.rb +++ b/lib/common/db_updater.rb @@ -13,8 +13,13 @@ class DbUpdater def initialize(repo_directory) @repo_directory = repo_directory - fail "#{repo_directory} is not writable" unless \ - Pathname.new(repo_directory).writable? + unless Dir.exist?(@repo_directory) + FileUtils.mkdir_p(@repo_directory) + end + + unless Pathname.new(@repo_directory).writable? + fail "#{@repo_directory} is not writable" + end end # @return [ Hash ] The params for Typhoeus::Request