Don't stop installing applications after a failure

This commit is contained in:
Dmitry Rodionov 2016-09-06 21:28:24 +07:00
parent 319300e7a1
commit 642e804e28

View file

@ -12,13 +12,27 @@ struct InstallCommand: CommandType {
let function = "Install from the Mac App Store"
func run(options: Options) -> Result<(), MASError> {
for id in options.appIds {
// Try to download applications with given identifiers and collect results
let results = options.appIds.map { (id) -> Result<(), MASError> in
if let error = download(id) {
return .Failure(error)
} else {
return .Success()
}
}
return .Success(())
// See if at least one of the downloads failed
let errorIndex = results.indexOf {
if case .Failure(_) = $0 {
return true
}
return false
}
// And return an overrall general failure if there're failed downloads
if let _ = errorIndex {
return .Failure(MASError(code: .DownloadFailed))
} else {
return .Success()
}
}
}