cask/utils: quieten down when fixing permissions fails.
When fixing permissions fails, we should not print the error messages from e.g. `chmod` unless we are in debug or verbose mode (because we immediately retry taking ownership `sudo`).
This commit is contained in:
parent
865d38ab82
commit
7e35ae25d5
@ -68,15 +68,19 @@ module Cask
|
|||||||
rescue
|
rescue
|
||||||
# in case of permissions problems
|
# in case of permissions problems
|
||||||
unless tried_permissions
|
unless tried_permissions
|
||||||
|
print_stderr = Context.current.debug? || Context.current.verbose?
|
||||||
# TODO: Better handling for the case where path is a symlink.
|
# TODO: Better handling for the case where path is a symlink.
|
||||||
# The -h and -R flags cannot be combined, and behavior is
|
# The -h and -R flags cannot be combined, and behavior is
|
||||||
# dependent on whether the file argument has a trailing
|
# dependent on whether the file argument has a trailing
|
||||||
# slash. This should do the right thing, but is fragile.
|
# slash. This should do the right thing, but is fragile.
|
||||||
command.run("/usr/bin/chflags",
|
command.run("/usr/bin/chflags",
|
||||||
|
print_stderr:,
|
||||||
args: command_args + ["--", "000", path])
|
args: command_args + ["--", "000", path])
|
||||||
command.run("/bin/chmod",
|
command.run("/bin/chmod",
|
||||||
|
print_stderr:,
|
||||||
args: command_args + ["--", "u+rwx", path])
|
args: command_args + ["--", "u+rwx", path])
|
||||||
command.run("/bin/chmod",
|
command.run("/bin/chmod",
|
||||||
|
print_stderr:,
|
||||||
args: command_args + ["-N", path])
|
args: command_args + ["-N", path])
|
||||||
tried_permissions = true
|
tried_permissions = true
|
||||||
retry # rmtree
|
retry # rmtree
|
||||||
|
@ -171,12 +171,7 @@ RSpec.describe Cask::Artifact::App, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "overwrites the existing app" do
|
it "overwrites the existing app" do
|
||||||
expect(command).to receive(:run).with("/usr/bin/chflags",
|
expect(command).to receive(:run).and_call_original.at_least(:once)
|
||||||
args: ["-R", "--", "000", target_path]).and_call_original
|
|
||||||
expect(command).to receive(:run).with("/bin/chmod",
|
|
||||||
args: ["-R", "--", "u+rwx", target_path]).and_call_original
|
|
||||||
expect(command).to receive(:run).with("/bin/chmod",
|
|
||||||
args: ["-R", "-N", target_path]).and_call_original
|
|
||||||
|
|
||||||
stdout = <<~EOS
|
stdout = <<~EOS
|
||||||
==> Removing App '#{target_path}'
|
==> Removing App '#{target_path}'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user