Skip to content

Commit ef0631b

Browse files
committed
Change default pstore_dir to subdir in Gem.cache_home
So it's now XDG conform and also Ruby ecosystem conform.
1 parent f6ce109 commit ef0631b

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

lib/mini_exiftool.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,17 @@ def self.unify tag
366366

367367
def self.pstore_dir
368368
unless defined? @@pstore_dir
369-
# This will hopefully work on *NIX and Windows systems
370-
home = ENV['HOME'] || ENV['HOMEDRIVE'] + ENV['HOMEPATH'] || ENV['USERPROFILE']
371-
subdir = @@running_on_windows ? '_mini_exiftool' : '.mini_exiftool'
372-
@@pstore_dir = File.join(home, subdir)
369+
@@pstore_dir =
370+
if env = ENV['MINI_EXIFTOOL_PSTORE_DIR']
371+
env
372+
elsif defined?(Gem.cache_home) && File.writable?(Gem.cache_home)
373+
File.join(Gem.cache_home, 'mini_exiftool')
374+
else
375+
# This fallback will hopefully work on *NIX and Windows systems
376+
home = ENV['HOME'] || ENV['HOMEDRIVE'] + ENV['HOMEPATH'] || ENV['USERPROFILE']
377+
subdir = @@running_on_windows ? '_mini_exiftool' : '.mini_exiftool'
378+
File.join(home, subdir)
379+
end
373380
end
374381
@@pstore_dir
375382
end

0 commit comments

Comments
 (0)