Save flags in with_full_permissions.
This commit is contained in:
parent
9393b16930
commit
642e355b4f
@ -92,12 +92,14 @@ module Hbc
|
|||||||
|
|
||||||
def with_full_permissions(path)
|
def with_full_permissions(path)
|
||||||
original_mode = (path.stat.mode % 01000).to_s(8)
|
original_mode = (path.stat.mode % 01000).to_s(8)
|
||||||
# TODO: similarly read and restore macOS flags (cf man chflags)
|
original_flags = @command.run!("/usr/bin/stat", args: ["-f", "%Of", "--", path]).stdout.chomp
|
||||||
|
|
||||||
@command.run!("/bin/chmod", args: ["--", "777", path], sudo: true)
|
@command.run!("/bin/chmod", args: ["--", "777", path], sudo: true)
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
if path.exist? # block may have removed dir
|
if path.exist? # block may have removed dir
|
||||||
@command.run!("/bin/chmod", args: ["--", original_mode, path], sudo: true)
|
@command.run!("/bin/chmod", args: ["--", original_mode, path], sudo: true)
|
||||||
|
@command.run!("/usr/bin/chflags", args: ["--", original_flags, path], sudo: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
describe Hbc::Pkg, :cask do
|
describe Hbc::Pkg, :cask do
|
||||||
describe "#uninstall" do
|
describe "#uninstall" do
|
||||||
let(:fake_system_command) { Hbc::NeverSudoSystemCommand }
|
let(:fake_system_command) { Hbc::NeverSudoSystemCommand }
|
||||||
let(:empty_response) { double(stdout: "", plist: {"volume" => "/", "install-location" => "", "paths" => {}}) }
|
let(:empty_response) { double(stdout: "", plist: { "volume" => "/", "install-location" => "", "paths" => {} }) }
|
||||||
let(:pkg) { described_class.new("my.fake.pkg", fake_system_command) }
|
let(:pkg) { described_class.new("my.fake.pkg", fake_system_command) }
|
||||||
|
|
||||||
it "removes files and dirs referenced by the pkg" do
|
it "removes files and dirs referenced by the pkg" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user