Skip to content
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
83 changes: 57 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ on:
- main
- release/*
paths:
- 'Sources/**'
- 'Tests/**'
- 'Examples/**'
- '*.swift'
- 'Package.swift'
- 'Package.resolved'
- '.github/workflows/ci.yml'
- 'Makefile'
- '*.xcodeproj/**'
- '*.xcworkspace/**'
- '.swiftpm/**'
- "Sources/**"
- "Tests/**"
- "Examples/**"
- "*.swift"
- "Package.swift"
- "Package.resolved"
- ".github/workflows/ci.yml"
- "Makefile"
- "*.xcodeproj/**"
- "*.xcworkspace/**"
- ".swiftpm/**"
pull_request:
branches:
- "*"
- release/*
paths:
- 'Sources/**'
- 'Tests/**'
- 'Examples/**'
- '*.swift'
- 'Package.swift'
- 'Package.resolved'
- '.github/workflows/ci.yml'
- 'Makefile'
- '*.xcodeproj/**'
- '*.xcworkspace/**'
- '.swiftpm/**'
- "Sources/**"
- "Tests/**"
- "Examples/**"
- "*.swift"
- "Package.swift"
- "Package.resolved"
- ".github/workflows/ci.yml"
- "Makefile"
- "*.xcodeproj/**"
- "*.xcworkspace/**"
- ".swiftpm/**"
workflow_dispatch:

concurrency:
Expand All @@ -55,6 +55,14 @@ jobs:
- { command: test, skip_release: 1 }
steps:
- uses: actions/checkout@v5
- name: Cache derived data
uses: actions/cache@v4
with:
path: ~/.derivedData
key: |
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
restore-keys: |
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: List available devices
Expand Down Expand Up @@ -119,7 +127,7 @@ jobs:
spm:
runs-on: macos-15
strategy:
matrix:
matrix:
config: [debug, release]
steps:
- uses: actions/checkout@v5
Expand All @@ -136,11 +144,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: "Remove IntegrationTests"
run: rm -r Tests/IntegrationTests/*
- name: "Cache Swift Package"
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: "Build Swift Package"
run: swift build

- name: "Test Swift Package"
run: swift test --skip IntegrationTests

# android:
# name: Android
# runs-on: ubuntu-latest
Expand All @@ -164,6 +179,14 @@ jobs:
xcode: ["16.3"]
steps:
- uses: actions/checkout@v5
- name: Cache derived data
uses: actions/cache@v4
with:
path: ~/.derivedData
key: |
deriveddata-library-evolution-${{ matrix.xcode }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
restore-keys: |
deriveddata-library-evolution-${{ matrix.xcode }}-
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Build for library evolution
Expand Down Expand Up @@ -200,5 +223,13 @@ jobs:
runs-on: macos-15
steps:
- uses: actions/checkout@v5
- name: Cache Swift build
uses: actions/cache@v4
with:
path: .build
key: |
docs-${{ runner.os }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
docs-${{ runner.os }}-
- name: Test docs
run: make test-docs
70 changes: 48 additions & 22 deletions Sources/Storage/MultipartFormData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,17 @@ class MultipartFormData {
var buffer = [UInt8](repeating: 0, count: streamBufferSize)
let bytesRead = inputStream.read(&buffer, maxLength: streamBufferSize)

if let error = inputStream.streamError {
throw MultipartFormDataError.inputStreamReadFailed(error: error)
if bytesRead < 0 {
if let error = inputStream.streamError {
throw MultipartFormDataError.inputStreamReadFailed(error: error)
} else {
throw MultipartFormDataError.inputStreamReadFailed(
error: MultipartFormDataError.UnexpectedInputStreamLength(
bytesExpected: bodyPart.bodyContentLength,
bytesRead: UInt64(encoded.count)
)
)
}
}

if bytesRead > 0 {
Expand Down Expand Up @@ -474,9 +483,17 @@ class MultipartFormData {
let bufferSize = min(streamBufferSize, Int(bytesLeftToRead))
var buffer = [UInt8](repeating: 0, count: bufferSize)
let bytesRead = inputStream.read(&buffer, maxLength: bufferSize)

if let streamError = inputStream.streamError {
throw MultipartFormDataError.inputStreamReadFailed(error: streamError)
if bytesRead < 0 {
if let streamError = inputStream.streamError {
throw MultipartFormDataError.inputStreamReadFailed(error: streamError)
} else {
throw MultipartFormDataError.inputStreamReadFailed(
error: MultipartFormDataError.UnexpectedInputStreamLength(
bytesExpected: bodyPart.bodyContentLength,
bytesRead: bodyPart.bodyContentLength - bytesLeftToRead
)
)
}
}

if bytesRead > 0 {
Expand Down Expand Up @@ -514,8 +531,17 @@ class MultipartFormData {
while bytesToWrite > 0, outputStream.hasSpaceAvailable {
let bytesWritten = outputStream.write(buffer, maxLength: bytesToWrite)

if let error = outputStream.streamError {
throw MultipartFormDataError.outputStreamWriteFailed(error: error)
if bytesWritten < 0 {
if let error = outputStream.streamError {
throw MultipartFormDataError.outputStreamWriteFailed(error: error)
} else {
throw MultipartFormDataError.outputStreamWriteFailed(
error: MultipartFormDataError.UnexpectedInputStreamLength(
bytesExpected: UInt64(buffer.count),
bytesRead: UInt64(buffer.count - bytesToWrite)
)
)
}
}

bytesToWrite -= bytesWritten
Expand Down Expand Up @@ -650,10 +676,10 @@ enum MultipartFormDataError: Error {

var underlyingError: (any Error)? {
switch self {
case let .bodyPartFileNotReachableWithError(_, error),
let .bodyPartFileSizeQueryFailedWithError(_, error),
let .inputStreamReadFailed(error),
let .outputStreamWriteFailed(error):
case .bodyPartFileNotReachableWithError(_, let error),
.bodyPartFileSizeQueryFailedWithError(_, let error),
.inputStreamReadFailed(let error),
.outputStreamWriteFailed(let error):
error

case .bodyPartURLInvalid,
Expand All @@ -671,17 +697,17 @@ enum MultipartFormDataError: Error {

var url: URL? {
switch self {
case let .bodyPartURLInvalid(url),
let .bodyPartFilenameInvalid(url),
let .bodyPartFileNotReachable(url),
let .bodyPartFileNotReachableWithError(url, _),
let .bodyPartFileIsDirectory(url),
let .bodyPartFileSizeNotAvailable(url),
let .bodyPartFileSizeQueryFailedWithError(url, _),
let .bodyPartInputStreamCreationFailed(url),
let .outputStreamFileAlreadyExists(url),
let .outputStreamURLInvalid(url),
let .outputStreamCreationFailed(url):
case .bodyPartURLInvalid(let url),
.bodyPartFilenameInvalid(let url),
.bodyPartFileNotReachable(let url),
.bodyPartFileNotReachableWithError(let url, _),
.bodyPartFileIsDirectory(let url),
.bodyPartFileSizeNotAvailable(let url),
.bodyPartFileSizeQueryFailedWithError(let url, _),
.bodyPartInputStreamCreationFailed(let url),
.outputStreamFileAlreadyExists(let url),
.outputStreamURLInvalid(let url),
.outputStreamCreationFailed(let url):
url

case .inputStreamReadFailed, .outputStreamWriteFailed:
Expand Down
21 changes: 14 additions & 7 deletions Supabase.xcworkspace/xcshareddata/xcschemes/Supabase.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AuthTests"
Expand All @@ -155,7 +156,8 @@
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FunctionsTests"
Expand All @@ -165,7 +167,8 @@
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "HelpersTests"
Expand All @@ -175,7 +178,8 @@
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PostgRESTTests"
Expand All @@ -185,7 +189,8 @@
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "RealtimeTests"
Expand All @@ -195,7 +200,8 @@
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "StorageTests"
Expand All @@ -205,7 +211,8 @@
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
skipped = "NO"
parallelizable = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SupabaseTests"
Expand Down
Loading
Loading