From 129a45d2006119352ed7c53003bcc6fea7a52209 Mon Sep 17 00:00:00 2001 From: Eric Amorde Date: Sun, 4 Feb 2024 16:30:24 -0800 Subject: [PATCH] Fix an issue attempting to re-copy the same file when the destination does not have write permissions --- lib/cocoapods/downloader/cache.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cocoapods/downloader/cache.rb b/lib/cocoapods/downloader/cache.rb index ebb498df6a..7044880219 100644 --- a/lib/cocoapods/downloader/cache.rb +++ b/lib/cocoapods/downloader/cache.rb @@ -327,13 +327,15 @@ def copy_source_and_clean(source, destination, spec) # @return [Void] # def copy_files(files, source, destination) - files = files.select { |f| File.exist?(f) } + files = files + .map { |f| Pathname(f) } + .select { |p| p.exist? && p.file? } destination.parent.mkpath Cache.write_lock(destination) do FileUtils.rm_rf(destination) destination.mkpath files_by_dir = files.group_by do |file| - relative_path = Pathname(file).relative_path_from(Pathname(source)).to_s + relative_path = file.relative_path_from(source) destination_path = File.join(destination, relative_path) File.dirname(destination_path) end