From 360a30150350aff6841a4f530add2c67487278c1 Mon Sep 17 00:00:00 2001 From: "Andrew R. McBurney" Date: Mon, 21 May 2018 12:13:03 -0400 Subject: [PATCH] Fix file path issue caused by dbm implicitly appending `.db` to end of file path provided. --- Library/Homebrew/cache_store.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cache_store.rb b/Library/Homebrew/cache_store.rb index 8a1c7c334d..f313ee4c06 100644 --- a/Library/Homebrew/cache_store.rb +++ b/Library/Homebrew/cache_store.rb @@ -29,7 +29,7 @@ class DatabaseCache # @return [DBM] db def db # DBM::WRCREAT: Creates the database if it does not already exist - @db ||= DBM.open(cache_path, DATABASE_MODE, DBM::WRCREAT) + @db ||= DBM.open(dbm_file_path, DATABASE_MODE, DBM::WRCREAT) end # Returns `true` if the cache is empty for the given `@type` @@ -53,12 +53,20 @@ class DatabaseCache @db&.close end + # `DBM` appends `.db` file extension to the path provided, which is why it's + # not included + # + # @return [String] + def dbm_file_path + File.join(HOMEBREW_CACHE, @type.to_s) + end + # The path where the database resides in the `HOMEBREW_CACHE` for the given # `@type` # # @return [String] def cache_path - File.join(HOMEBREW_CACHE, "#{@type}.db") + "#{dbm_file_path}.db" end end