cask: fix writability check backing up an artifact

This commit is contained in:
Ilya Kulakov 2023-01-13 13:37:50 -08:00
parent 3e257890da
commit 3d16112b14
2 changed files with 16 additions and 1 deletions

View File

@ -114,7 +114,7 @@ module Cask
source.dirname.mkpath
# We need to preserve extended attributes between copies.
command.run!("/bin/cp", args: ["-pR", target, source], sudo: !target.parent.writable?)
command.run!("/bin/cp", args: ["-pR", target, source], sudo: !source.parent.writable?)
delete(target, force: force, command: command, **options)
end

View File

@ -263,6 +263,11 @@ describe Cask::Artifact::App, :cask do
end
describe "uninstall_phase" do
after do
FileUtils.chmod 0755, target_path if target_path.exist?
FileUtils.chmod 0755, source_path if source_path.exist?
end
it "deletes managed apps" do
install_phase
@ -272,6 +277,16 @@ describe Cask::Artifact::App, :cask do
expect(target_path).not_to exist
end
it "backs up read-only managed apps" do
install_phase
FileUtils.chmod 0544, target_path
expect { uninstall_phase }.to raise_error(Errno::ENOTEMPTY)
expect(source_path).to be_a_directory
end
end
describe "summary" do