Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update usage of unsafe API, upgrade libarchive to 3.7.4, upgrade async http client #120

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"originHash" : "4e45e73ff02865a9bd0426ba4c6cd8dfcb967e62e7663128dd262908109e1487",
"pins" : [
{
"identity" : "async-http-client",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client",
"state" : {
"revision" : "fb308ee72f3d4c082a507033f94afa7395963ef3",
"version" : "1.21.0"
"revision" : "0ae99db85b2b9d1e79b362bd31fd1ffe492f7c47",
"version" : "1.21.2"
}
},
{
Expand Down Expand Up @@ -136,5 +137,5 @@
}
}
],
"version" : 2
"version" : 3
}
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
.package(url: "https://github.com/swift-server/async-http-client", from: "1.21.0"),
.package(url: "https://github.com/swift-server/async-http-client", from: "1.21.2"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.64.0"),
.package(url: "https://github.com/apple/swift-tools-support-core.git", from: "0.6.1"),
],
Expand Down
12 changes: 2 additions & 10 deletions Sources/SwiftlyCore/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ public protocol HTTPRequestExecutor {

/// An `HTTPRequestExecutor` backed by an `HTTPClient`.
internal struct HTTPRequestExecutorImpl: HTTPRequestExecutor {
fileprivate static let client = HTTPClientWrapper()

public func execute(_ request: HTTPClientRequest, timeout: TimeAmount) async throws -> HTTPClientResponse {
try await Self.client.inner.execute(request, timeout: timeout)
try await HTTPClient.shared.execute(request, timeout: timeout)
}
}

Expand Down Expand Up @@ -166,9 +164,7 @@ public struct SwiftlyHTTPClient {
for try await buffer in response.body {
receivedBytes += buffer.readableBytes

try buffer.withUnsafeReadableBytes { bufferPtr in
try fileHandle.write(contentsOf: bufferPtr)
}
try fileHandle.write(contentsOf: buffer.readableBytesView)

let now = Date()
if let reportProgress, lastUpdate.distance(to: now) > 0.25 || receivedBytes == expectedBytes {
Expand All @@ -183,7 +179,3 @@ public struct SwiftlyHTTPClient {
try fileHandle.synchronize()
}
}

private class HTTPClientWrapper {
fileprivate let inner = HTTPClient.shared
}
2 changes: 1 addition & 1 deletion scripts/install-libarchive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -o errexit

# TODO detect platform
LIBARCHIVE_VERSION=3.6.1
LIBARCHIVE_VERSION=3.7.4

mkdir /tmp/archive-build
pushd /tmp/archive-build
Expand Down