Skip to content

Commit

Permalink
Latest Updates (#33)
Browse files Browse the repository at this point in the history
### Goals ⚽
This PR updates dependencies and fixes a small sendability issue.
  • Loading branch information
jshier authored Oct 10, 2023
1 parent 51b0b67 commit 7a3465b
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 73 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@ jobs:
name: macOS
runs-on: firebreak
env:
DEVELOPER_DIR: /Applications/Xcode_14.3.1.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: SPM Test
run: swift test -c debug --sanitize=thread
Linux:
name: Linux
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
container:
image: swift:5.8.1-jammy
image: swift:5.9.0-jammy
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: SPM Linux Test
run: swift test -c debug
Linux_Nightly:
name: Linux Nightly
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
container:
image: swiftlang/swift:nightly-jammy
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: SPM Linux Test
run: swift test -c debug
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
name: Upload Release Artifact
runs-on: firebreak
env:
DEVELOPER_DIR: /Applications/Xcode_14.3.1.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build for Release
run: swift build -c release --arch arm64 --arch x86_64
- name: "Strip Artifact"
Expand Down
3 changes: 1 addition & 2 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# file options

--symlinks ignore
--swiftversion 5.8
--swiftversion 5.9

# rules
--enable isEmpty
Expand All @@ -10,7 +10,6 @@

# format options

--closingparen same-line
--commas inline
--comments indent
--decimalgrouping 3,5
Expand Down
49 changes: 20 additions & 29 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"state" : {
"revision" : "78db67e5bf4a8543075787f228e8920097319281",
"version" : "1.18.0"
"revision" : "16f7e62c08c6969899ce6cc277041e868364e5cf",
"version" : "1.19.0"
}
},
{
Expand All @@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/console-kit.git",
"state" : {
"revision" : "447f1046fb4e9df40973fe426ecb24a6f0e8d3b4",
"version" : "4.6.0"
"revision" : "d4b580e466c61f82a46d6bcc0b356add388f7ad2",
"version" : "4.8.1"
}
},
{
Expand All @@ -50,44 +50,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-algorithms.git",
"state" : {
"revision" : "b14b7f4c528c942f121c8b860b9410b2bf57825e",
"version" : "1.0.0"
"revision" : "bcd4f369ac962bc3e5244c9df778739f8f5bdbf1",
"version" : "1.1.0"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "6c89474e62719ddcc1e9614989fff2f68208fe10",
"version" : "1.1.0"
}
},
{
"identity" : "swift-backtrace",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/swift-backtrace.git",
"state" : {
"revision" : "f25620d5d05e2f1ba27154b40cafea2b67566956",
"version" : "1.3.3"
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version" : "1.0.4"
"revision" : "a902f1823a7ff3c9ab2fba0f992396b948eda307",
"version" : "1.0.5"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "60f13f60c4d093691934dc6cfdf5f508ada1f894",
"version" : "2.6.0"
"revision" : "b51f1d6845b353a2121de1c6a670738ec33561a6",
"version" : "3.1.0"
}
},
{
Expand All @@ -113,26 +104,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "cf281631ff10ec6111f2761052aa81896a83a007",
"version" : "2.58.0"
"revision" : "3db5c4aeee8100d2db6f1eaf3864afdad5dc68fd",
"version" : "2.59.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "0e0d0aab665ff1a0659ce75ac003081f2b1c8997",
"version" : "1.19.0"
"revision" : "fb70a0f5e984f23be48b11b4f1909f3bee016178",
"version" : "1.19.1"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "a8ccf13fa62775277a5d56844878c828bbb3be1a",
"version" : "1.27.0"
"revision" : "3798fe5f1564f27461390b4f6163f6ddfb21fd2d",
"version" : "1.28.0"
}
},
{
Expand Down Expand Up @@ -167,8 +158,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/vapor.git",
"state" : {
"revision" : "1bb4a2ed94bec7a92f92e82896408c785d068f5c",
"version" : "4.79.0"
"revision" : "61c8104bf688439e4f3f793c9d0746f11d9f846a",
"version" : "4.84.5"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/Compression.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// BasicAuth.swift
// Compression.swift
//
// Copyright (c) 2020 Alamofire Software Foundation (http://alamofire.org/)
//
Expand Down
6 changes: 3 additions & 3 deletions Sources/Download.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func createDownloadRoutes(for app: Application) throws {
let byteCount = range.ranges.reduce(0) { result, value in
switch value {
case let .start(value):
return result + (totalCount - value)
result + (totalCount - value)
case let .tail(value):
return result + value
result + value
case let .within(start, end):
return result + (end - start)
result + (end - start)
}
}

Expand Down
48 changes: 24 additions & 24 deletions Sources/Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,63 +47,63 @@ private enum Image: String, Decodable {
var contentType: HTTPMediaType {
switch self {
case .avif:
return HTTPMediaType(type: "image", subType: "avif")
HTTPMediaType(type: "image", subType: "avif")
case .bmp:
return HTTPMediaType(type: "image", subType: "x-ms-bmp")
HTTPMediaType(type: "image", subType: "x-ms-bmp")
case .jp2:
return HTTPMediaType(type: "image", subType: "jp2")
HTTPMediaType(type: "image", subType: "jp2")
case .jpeg:
return .jpeg
.jpeg
case .jxl:
return HTTPMediaType(type: "image", subType: "jxl")
HTTPMediaType(type: "image", subType: "jxl")
case .gif:
return .gif
.gif
case .heic:
return HTTPMediaType(type: "image", subType: "heic")
HTTPMediaType(type: "image", subType: "heic")
case .heif:
return HTTPMediaType(type: "image", subType: "heif")
HTTPMediaType(type: "image", subType: "heif")
case .pdf:
return .pdf
.pdf
case .png:
return .png
.png
case .tiff:
return HTTPMediaType(type: "image", subType: "tiff")
HTTPMediaType(type: "image", subType: "tiff")
case .webp:
return HTTPMediaType(type: "image", subType: "webp")
HTTPMediaType(type: "image", subType: "webp")
}
}

var encodedImage: String {
switch self {
case .avif:
return """
"""
AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF\
2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdj\
AxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xyb\
mNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=
"""
case .bmp:
return "Qk0eAAAAAAAAABoAAAAMAAAAAQABAAEAGAAAAP8A"
"Qk0eAAAAAAAAABoAAAAMAAAAAQABAAEAGAAAAP8A"
case .jp2:
return """
"""
AAAADGpQICANCocKAAAAFGZ0eXBqcDIgAAAAAGpwMiAAAAAtanAyaAAAABZpaGRyAAAAAQAAAAEAAwcHAAAAAAAPY29scgEAAAAAABA\
AAAAAanAyY/9P/1EALwAAAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAwcBAQcBAQcBAf9cAA1AQEhIUEhIUEhIUP9SAA\
wAAAABAQMEBAAB/2QADgABTFRfSlAyXzIyMP+QAAoAAAAAAB0AAf+T34AIB4CAgICAgICAgICA/9k=
"""
case .jpeg:
return """
"""
/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAA\
BAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=
"""
case .jxl:
return """
"""
/wo6HwGRCAYBAKQBC4ALbNQxslZLlFdAkOAPoAehB5BJcYD1Lo0WYXbZB4vCxGjuQc6x/4UgLq5cjpgHPfUXsGDCgv45dgEZBArgt1YI\
436HAHKD5uNY+OGH8BV0jPMRJGl0oiUXUAHBDV4eWQQw6vhLEg4A
"""
case .gif:
return "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
"R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
case .heic:
return """
"""
AAAAGGZ0eXBoZWljAAAAAGhlaWNtaWYxAAABtW1ldGEAAAAAAAAAImhkbHIAAAAAAAAAAHBpY3QAAAAAAAAAAAAAAAAAAAAAACRkaW5\
mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAA5waXRtAAAAAAABAAAAOGlpbmYAAAAAAAIAAAAVaW5mZQIAAAAAAQAAaHZjMQ\
AAAAAVaW5mZQIAAAEAAgAARXhpZgAAAAAaaXJlZgAAAAAAAAAOY2RzYwACAAEAAQAAANdpcHJwAAAAt2lwY28AAAATY29scm5jbHgAA\
Expand All @@ -114,24 +114,24 @@ private enum Image: String, Decodable {
8K8K8K8K8K8K8K8+8h9YbnhyPHF8zZ/kV9X
"""
case .heif:
return """
"""
AAAAGGZ0eXBoZWljAAAAAG1pZjFoZWljAAABKm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAHBpY3QAXABjADEANQB4ADIAAAAADnBpdG0\
AAAAAAAEAAAAiaWxvYwAAAABEQAABAAEAAAAAAUoAAQAAAAAAAAA4AAAAI2lpbmYAAAAAAAEAAAAVaW5mZQIAAAAAAQAAaHZjMQAAAA\
CqaXBycAAAAI1pcGNvAAAAcWh2Y0MBBAgAAAAAAAAAAAD/8AD8/fj4AAAPAyAAAQAXQAEMAf//BAgAAAMAn6gAAAMAAP+6AkAhAAEAJ\
kIBAQQIAAADAJ+oAAADAAD/oCCBBZbqSSiuAQAAAwABAAADAAEIIgABAAZEAcFxiRIAAAAUaXNwZQAAAAAAAABAAAAAQAAAABVpcG1h\
AAAAAAAAAAEAAQKBAgAAAEBtZGF0AAAANCgBrwW4FIPqI0Af91/uf7X9b878787878989898989898989/4UETMJZQNe2nK06cUg1sA=
"""
case .pdf:
return """
"""
JVBERi0xLgoxIDAgb2JqPDwvUGFnZXMgMiAwIFI+PmVuZG9iagoyIDAgb2JqPDwvS2lkc1szIDAgUl0vQ291bnQgMT4+ZW5kb2JqCjM\
gMCBvYmo8PC9QYXJlbnQgMiAwIFI+PmVuZG9iagp0cmFpbGVyIDw8L1Jvb3QgMSAwIFI+Pg==
"""
case .png:
return "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="
case .tiff:
return "TU0AKgAAAAgAAwEAAAMAAAABAAEAAAEBAAMAAAABAAEAAAERAAMAAAABAAAAAA=="
"TU0AKgAAAAgAAwEAAAMAAAABAAEAAAEBAAMAAAABAAEAAAERAAMAAAABAAAAAA=="
case .webp:
return "UklGRhYAAABXRUJQVlA4TAkAAAAvAAAAAIiI/gcA"
"UklGRhYAAABXRUJQVlA4TAkAAAAvAAAAAIiI/gcA"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Inspection.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Protected.swift
// Inspection.swift
//
// Copyright (c) 2022 Alamofire Software Foundation (http://alamofire.org/)
//
Expand Down
2 changes: 1 addition & 1 deletion Sources/Protected.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Inspection.swift
// Protected.swift
//
// Copyright (c) 2022 Alamofire Software Foundation (http://alamofire.org/)
//
Expand Down
6 changes: 3 additions & 3 deletions Sources/Upload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ func createUploadRoutes(for app: Application) throws {
app.on(.POST, "upload", body: .stream) { request -> EventLoopFuture<Response> in
let promise = request.eventLoop.makePromise(of: Response.self)

var bytesReceived = 0
let bytesReceived = Protected(0)
request.body.drain { result in
switch result {
case let .buffer(buffer):
bytesReceived += buffer.readableBytes
bytesReceived.write { $0 += buffer.readableBytes }
request.logger.info("Received \(bytesReceived) bytes so far.")
return request.eventLoop.makeSucceededVoidFuture()
case let .error(error):
Expand All @@ -42,7 +42,7 @@ func createUploadRoutes(for app: Application) throws {
app.logger.info("Upload of \(bytesReceived) bytes completed.")
let response: Response
do {
let uploadResponse = UploadResponse(bytes: bytesReceived)
let uploadResponse = UploadResponse(bytes: bytesReceived.wrappedValue)
let buffer = try JSONEncoder().encodeAsByteBuffer(uploadResponse, allocator: request.application.allocator)
response = Response(status: .ok, body: .init(buffer: buffer))
} catch {
Expand Down

0 comments on commit 7a3465b

Please sign in to comment.