summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-09-23 13:45:45 +0200
committerSamuel Giddins <segiddins@segiddins.me>2016-09-23 13:45:45 +0200
commit5f5e350017a1c7feb7315e45fd9a8298dee69efc (patch)
tree430529642c9cca0a26a21a6c922c8440e6b80644
parent336b070bc9a11145ea3307c8a6c1477ee5dde4a5 (diff)
downloadbundler-seg-unvendor-compact-index-client.tar.gz
Use filesystem_access in the compact indexseg-unvendor-compact-index-client
-rw-r--r--lib/bundler/compact_index_client/cache.rb8
-rw-r--r--lib/bundler/compact_index_client/updater.rb12
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/bundler/compact_index_client/cache.rb b/lib/bundler/compact_index_client/cache.rb
index 951909da0e..e44f05dc7e 100644
--- a/lib/bundler/compact_index_client/cache.rb
+++ b/lib/bundler/compact_index_client/cache.rb
@@ -8,7 +8,11 @@ module Bundler
def initialize(directory)
@directory = Pathname.new(directory).expand_path
- info_roots.each {|dir| FileUtils.mkdir_p(dir) }
+ info_roots.each do |dir|
+ SharedHelpers.filesystem_access(dir) do
+ FileUtils.mkdir_p(dir)
+ end
+ end
end
def names
@@ -84,7 +88,7 @@ module Bundler
def lines(path)
return [] unless path.file?
- lines = path.read.split("\n")
+ lines = SharedHelpers.filesystem_access(path, :read, &:read).split("\n")
header = lines.index("---")
header ? lines[header + 1..-1] : lines
end
diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb
index f75cbde819..03a063beb5 100644
--- a/lib/bundler/compact_index_client/updater.rb
+++ b/lib/bundler/compact_index_client/updater.rb
@@ -49,11 +49,15 @@ module Bundler
end
mode = response.is_a?(Net::HTTPPartialContent) ? "a" : "w"
- local_temp_path.open(mode) {|f| f << content }
+ SharedHelpers.filesystem_access(local_temp_path) do
+ local_temp_path.open(mode) {|f| f << content }
+ end
response_etag = response["ETag"].gsub(%r{\AW/}, "")
if etag_for(local_temp_path) == response_etag
- FileUtils.mv(local_temp_path, local_path)
+ SharedHelpers.filesystem_access(local_path) do
+ FileUtils.mv(local_temp_path, local_path)
+ end
return nil
end
@@ -75,7 +79,9 @@ module Bundler
# This must use IO.read instead of Digest.file().hexdigest
# because we need to preserve \n line endings on windows when calculating
# the checksum
- Digest::MD5.hexdigest(IO.read(path))
+ SharedHelpers.filesystem_access(path, :read) do
+ Digest::MD5.hexdigest(IO.read(path))
+ end
end
end
end