summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Lance <stefan@lances.net>2015-09-11 09:23:12 -0500
committerStefan Lance <stefan@lances.net>2015-09-11 09:23:12 -0500
commit3587e70b2d4b0f57e3edf696a61ff180c6cf8fd1 (patch)
tree73fad1ef42e2b46fe75d3e3b4457fb5df94cfa03
parente853522c11ff19499a2faafeca170d00132d841e (diff)
downloadbundler-3587e70b2d4b0f57e3edf696a61ff180c6cf8fd1.tar.gz
Don't cache globally if there is no remote
-rw-r--r--lib/bundler/source/rubygems.rb14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index cbdcd184de..03a4eb6eea 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -441,7 +441,7 @@ module Bundler
def cache_globally(spec, local_cache_path)
cache_path = download_cache_path("#{spec.full_name}.gem")
- unless cache_path.exist?
+ if cache_path && !cache_path.exist?
FileUtils.mkdir_p(cache_path)
FileUtils.cp(local_cache_path, cache_path)
end
@@ -450,14 +450,10 @@ module Bundler
def download_cache_path(*paths)
raise "Caching is only possible for sources with one URL" if remotes.size > 1
uri = remotes.first
- source_dir =
- if uri
- port = uri.port unless uri.port == 80
- path = Digest::MD5.hexdigest(uri.path) unless uri.path =~ %r|\A/?\Z|
- [uri.hostname, port, path].compact.join(".")
- else
- ""
- end
+ return unless uri
+ port = uri.port unless uri.port == 80
+ path = Digest::MD5.hexdigest(uri.path) unless uri.path =~ %r|\A/?\Z|
+ source_dir = [uri.hostname, port, path].compact.join(".")
Bundler.settings.download_cache_path.join(source_dir).tap(&:mkpath).join(*paths)
end
end