mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Authenticates before checking for AltServers
This means Auth flow is presented even when AltServer is not nearby.
This commit is contained in:
@@ -15,6 +15,7 @@ import AltSign
|
||||
class DownloadAppOperation: ResultOperation<ALTApplication>
|
||||
{
|
||||
let app: AppProtocol
|
||||
let context: AppOperationContext
|
||||
|
||||
private let bundleIdentifier: String
|
||||
private let sourceURL: URL
|
||||
@@ -22,9 +23,11 @@ class DownloadAppOperation: ResultOperation<ALTApplication>
|
||||
|
||||
private let session = URLSession(configuration: .default)
|
||||
|
||||
init(app: AppProtocol)
|
||||
init(app: AppProtocol, context: AppOperationContext)
|
||||
{
|
||||
self.app = app
|
||||
self.context = context
|
||||
|
||||
self.bundleIdentifier = app.bundleIdentifier
|
||||
self.sourceURL = app.url
|
||||
self.destinationURL = InstalledApp.fileURL(for: app)
|
||||
@@ -38,6 +41,12 @@ class DownloadAppOperation: ResultOperation<ALTApplication>
|
||||
{
|
||||
super.main()
|
||||
|
||||
if let error = self.context.error
|
||||
{
|
||||
self.finish(.failure(error))
|
||||
return
|
||||
}
|
||||
|
||||
print("Downloading App:", self.bundleIdentifier)
|
||||
|
||||
func finishOperation(_ result: Result<URL, Error>)
|
||||
|
||||
51
AltStore/Operations/FindServerOperation.swift
Normal file
51
AltStore/Operations/FindServerOperation.swift
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// FindServerOperation.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 9/8/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Roxas
|
||||
|
||||
@objc(FindServerOperation)
|
||||
class FindServerOperation: ResultOperation<Server>
|
||||
{
|
||||
let group: OperationGroup
|
||||
|
||||
init(group: OperationGroup)
|
||||
{
|
||||
self.group = group
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
override func main()
|
||||
{
|
||||
super.main()
|
||||
|
||||
if let error = self.group.error
|
||||
{
|
||||
self.finish(.failure(error))
|
||||
return
|
||||
}
|
||||
|
||||
if let server = ServerManager.shared.discoveredServers.first(where: { $0.isPreferred })
|
||||
{
|
||||
// Preferred server.
|
||||
self.finish(.success(server))
|
||||
}
|
||||
else if let server = ServerManager.shared.discoveredServers.first
|
||||
{
|
||||
// Any available server.
|
||||
self.finish(.success(server))
|
||||
}
|
||||
else
|
||||
{
|
||||
// No servers.
|
||||
self.finish(.failure(ConnectionError.serverNotFound))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user