lib/disco/data.rb in disco-0.4.2 vs lib/disco/data.rb in disco-0.5.0
- old
+ new
@@ -31,12 +31,11 @@
require "digest"
require "fileutils"
require "net/http"
require "tmpdir"
- # TODO handle this better
- raise "No HOME" unless ENV["HOME"]
- dest = "#{ENV["HOME"]}/.disco/#{fname}"
+ cache_home = ENV["XDG_CACHE_HOME"] || "#{ENV.fetch("HOME")}/.cache"
+ dest = "#{cache_home}/disco/#{fname}"
FileUtils.mkdir_p(File.dirname(dest))
return dest if File.exist?(dest)
temp_path = "#{Dir.tmpdir}/disco-#{Time.now.to_f}" # TODO better name