diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9068ed..1569b18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7e291a..a6c8415 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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" diff --git a/.swiftformat b/.swiftformat index bad8828..8402d47 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,7 +1,7 @@ # file options --symlinks ignore ---swiftversion 5.8 +--swiftversion 5.9 # rules --enable isEmpty @@ -10,7 +10,6 @@ # format options ---closingparen same-line --commas inline --comments indent --decimalgrouping 3,5 diff --git a/Package.resolved b/Package.resolved index a1c2254..d42bee0 100644 --- a/Package.resolved +++ b/Package.resolved @@ -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" } }, { @@ -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" } }, { @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-algorithms.git", "state" : { - "revision" : "b14b7f4c528c942f121c8b860b9410b2bf57825e", - "version" : "1.0.0" + "revision" : "bcd4f369ac962bc3e5244c9df778739f8f5bdbf1", + "version" : "1.1.0" } }, { @@ -59,17 +59,8 @@ "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" } }, { @@ -77,8 +68,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-collections.git", "state" : { - "revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2", - "version" : "1.0.4" + "revision" : "a902f1823a7ff3c9ab2fba0f992396b948eda307", + "version" : "1.0.5" } }, { @@ -86,8 +77,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-crypto.git", "state" : { - "revision" : "60f13f60c4d093691934dc6cfdf5f508ada1f894", - "version" : "2.6.0" + "revision" : "b51f1d6845b353a2121de1c6a670738ec33561a6", + "version" : "3.1.0" } }, { @@ -113,8 +104,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio.git", "state" : { - "revision" : "cf281631ff10ec6111f2761052aa81896a83a007", - "version" : "2.58.0" + "revision" : "3db5c4aeee8100d2db6f1eaf3864afdad5dc68fd", + "version" : "2.59.0" } }, { @@ -122,8 +113,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-extras.git", "state" : { - "revision" : "0e0d0aab665ff1a0659ce75ac003081f2b1c8997", - "version" : "1.19.0" + "revision" : "fb70a0f5e984f23be48b11b4f1909f3bee016178", + "version" : "1.19.1" } }, { @@ -131,8 +122,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-http2.git", "state" : { - "revision" : "a8ccf13fa62775277a5d56844878c828bbb3be1a", - "version" : "1.27.0" + "revision" : "3798fe5f1564f27461390b4f6163f6ddfb21fd2d", + "version" : "1.28.0" } }, { @@ -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" } }, { diff --git a/Sources/Compression.swift b/Sources/Compression.swift index bea8b94..f05eae6 100644 --- a/Sources/Compression.swift +++ b/Sources/Compression.swift @@ -1,5 +1,5 @@ // -// BasicAuth.swift +// Compression.swift // // Copyright (c) 2020 Alamofire Software Foundation (http://alamofire.org/) // diff --git a/Sources/Download.swift b/Sources/Download.swift index a46e2ee..f716dde 100644 --- a/Sources/Download.swift +++ b/Sources/Download.swift @@ -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) } } diff --git a/Sources/Images.swift b/Sources/Images.swift index 1abbf49..a609b2d 100644 --- a/Sources/Images.swift +++ b/Sources/Images.swift @@ -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\ @@ -114,7 +114,7 @@ private enum Image: String, Decodable { 8K8K8K8K8K8K8K8+8h9YbnhyPHF8zZ/kV9X """ case .heif: - return """ + """ AAAAGGZ0eXBoZWljAAAAAG1pZjFoZWljAAABKm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAHBpY3QAXABjADEANQB4ADIAAAAADnBpdG0\ AAAAAAAEAAAAiaWxvYwAAAABEQAABAAEAAAAAAUoAAQAAAAAAAAA4AAAAI2lpbmYAAAAAAAEAAAAVaW5mZQIAAAAAAQAAaHZjMQAAAA\ CqaXBycAAAAI1pcGNvAAAAcWh2Y0MBBAgAAAAAAAAAAAD/8AD8/fj4AAAPAyAAAQAXQAEMAf//BAgAAAMAn6gAAAMAAP+6AkAhAAEAJ\ @@ -122,16 +122,16 @@ private enum Image: String, Decodable { 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" } } diff --git a/Sources/Inspection.swift b/Sources/Inspection.swift index e436975..d945419 100644 --- a/Sources/Inspection.swift +++ b/Sources/Inspection.swift @@ -1,5 +1,5 @@ // -// Protected.swift +// Inspection.swift // // Copyright (c) 2022 Alamofire Software Foundation (http://alamofire.org/) // diff --git a/Sources/Protected.swift b/Sources/Protected.swift index 55de2eb..9a11dba 100644 --- a/Sources/Protected.swift +++ b/Sources/Protected.swift @@ -1,5 +1,5 @@ // -// Inspection.swift +// Protected.swift // // Copyright (c) 2022 Alamofire Software Foundation (http://alamofire.org/) // diff --git a/Sources/Upload.swift b/Sources/Upload.swift index 714e212..b0dbbd0 100644 --- a/Sources/Upload.swift +++ b/Sources/Upload.swift @@ -28,11 +28,11 @@ func createUploadRoutes(for app: Application) throws { app.on(.POST, "upload", body: .stream) { request -> EventLoopFuture 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): @@ -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 {