Cask: split quarantine/release functions

This commit is contained in:
L. E. Segovia 2018-09-08 14:00:44 +00:00
parent 53b95c6260
commit c7c14e1333
No known key found for this signature in database
GPG Key ID: D5D1DC48B52B7AD5
2 changed files with 37 additions and 33 deletions

View File

@ -49,7 +49,11 @@ module Cask
return if @quarantine.nil?
return unless Quarantine.available?
Quarantine.cask!(cask: @cask, download_path: @downloaded_path, action: @quarantine)
if @quarantine
Quarantine.cask!(cask: @cask, download_path: @downloaded_path)
else
Quarantine.release!(download_path: @downloaded_path)
end
end
end
end

View File

@ -67,10 +67,27 @@ module Cask
fields.join(";")
end
def release!(download_path: nil)
return unless detect(download_path)
odebug "Releasing #{download_path} from quarantine"
quarantiner = system_command("/usr/bin/xattr",
args: [
"-d",
QUARANTINE_ATTRIBUTE,
download_path,
],
print_stderr: false)
return if quarantiner.success?
raise CaskQuarantineReleaseError.new(download_path, quarantiner.stderr)
end
def cask!(cask: nil, download_path: nil, action: true)
return if cask.nil? || download_path.nil?
if action
return if detect(download_path)
odebug "Quarantining #{download_path}"
@ -91,23 +108,6 @@ module Cask
else
raise CaskQuarantineError.new(download_path, quarantiner.stderr)
end
else
return unless detect(download_path)
odebug "Releasing #{download_path} from quarantine"
quarantiner = system_command("/usr/bin/xattr",
args: [
"-d",
QUARANTINE_ATTRIBUTE,
download_path,
],
print_stderr: false)
return if quarantiner.success?
raise CaskQuarantineReleaseError.new(download_path, quarantiner.stderr)
end
end
def propagate(from: nil, to: nil)