Skip to content

Commit 0c6ba81

Browse files
committed
Improve fairtool launch script
1 parent cebedaa commit 0c6ba81

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

Sources/FairExpo/AltStoreAPI.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public struct AltStoreService : EndpointService {
8787
} else if downloadResponse.downloadExpired == true {
8888
// request processing, then continue to wait…
8989
logger("download expired for adpid=\(adpid), requesting re-download…")
90-
let request = try await request(AltStoreService.ADPProcessRequest(adpID: adpid))
90+
let processing = try await request(AltStoreService.ADPProcessRequest(adpID: adpid))
91+
logger("request processing for adpid=\(adpid) with status \(processing.status ?? "unknown")")
9192
try await Task.sleep(interval: 10)
9293
continue
9394
}
@@ -107,7 +108,7 @@ public struct AltStoreService : EndpointService {
107108
// try requesting the download
108109
logger("download unknown for adpid=\(adpid), requesting processing…")
109110
// TODO: these seem to trigger a 202 with no data when processing is initiated
110-
let request = try? await request(AltStoreService.ADPProcessRequest(adpID: adpid))
111+
_ = try await requestOptional(AltStoreService.ADPProcessRequest(adpID: adpid))
111112
try await Task.sleep(interval: 10)
112113
continue
113114
} else {

Sources/FairExpo/EndpointService.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ extension EndpointService {
110110
public func request<A: APIRequest>(_ request: A, cache: URLRequest.CachePolicy? = nil) async throws -> A.Response where A.Service == Self {
111111
try await decode(data: try session.fetch(request: buildRequest(for: request, cache: cache)).data)
112112
}
113+
114+
/// Perform a request, but permit the data to be empty and and return nil.
115+
public func requestOptional<A: APIRequest>(_ request: A, cache: URLRequest.CachePolicy? = nil) async throws -> A.Response? where A.Service == Self {
116+
let data = try await session.fetch(request: buildRequest(for: request, cache: cache)).data
117+
if data.isEmpty { return nil }
118+
return try decode(data: data)
119+
}
113120

114121
/// Fetches the web service for the given request, following the cursor until the `batchHandler` returns a non-`nil` response; the first response element will be returned
115122
@discardableResult public func requestBatches<T, A: CursoredAPIRequest>(_ request: A, cache: URLRequest.CachePolicy? = nil, interleaveDelay: TimeInterval? = 1.5, batchHandler: (_ requestIndex: Int, _ urlResponse: URLResponse?, _ batch: A.Response) throws -> T?) async throws -> T? where A.Service == Self {

scripts/package_fairtool.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ done
2828
# make a shell script that launches the right binary
2929
cat > fairtool-bin/fairtool << "EOF"
3030
#!/bin/bash
31-
set -eu
31+
set -e
3232
FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
33-
${FOLDER}/$(uname -s)/$(uname -m)/fairtool ${@}
33+
OS=$(uname -s)
34+
ARCH=$(uname -m)
35+
FAIRTOOL="${FOLDER}"/"${OS}"/"${ARCH}"/fairtool
36+
if [ "${OS}" = "Darwin" ]; then xattr -c "${FAIRTOOL}"; fi
37+
"${FAIRTOOL}" "${@}"
3438
EOF
3539
chmod +x fairtool-bin/fairtool
3640

0 commit comments

Comments
 (0)