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,46 +67,46 @@ 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)
return if detect(download_path)
odebug "Quarantining #{download_path}"
odebug "Quarantining #{download_path}"
quarantiner = system_command(swift,
args: [
QUARANTINE_SCRIPT,
download_path,
cask.url.to_s,
cask.homepage.to_s,
])
quarantiner = system_command(swift,
args: [
QUARANTINE_SCRIPT,
download_path,
cask.url.to_s,
cask.homepage.to_s,
])
return if quarantiner.success?
return if quarantiner.success?
case quarantiner.exit_status
when 2
raise CaskQuarantineError.new(download_path, "Insufficient parameters")
else
raise CaskQuarantineError.new(download_path, quarantiner.stderr)
end
case quarantiner.exit_status
when 2
raise CaskQuarantineError.new(download_path, "Insufficient parameters")
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)
raise CaskQuarantineError.new(download_path, quarantiner.stderr)
end
end