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

Remove a deadcode - the error variable will never be an AFError #22398

Merged
merged 1 commit into from
Jan 16, 2024
Merged
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
17 changes: 1 addition & 16 deletions WordPress/Classes/Services/MediaCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -809,22 +809,7 @@ extension Media {
let multipartEncodingFailedSampleError = AFError.multipartEncodingFailed(reason: .bodyPartFileNotReachable(at: URL(string: "https://wordpress.com")!)) as NSError
// (yes, yes, I know, unwrapped optional. but if creating a URL from this string fails, then something is probably REALLY wrong and we should bail anyway.)

// If we still have enough data to know this is a Swift Error, let's do the actual right thing here:
if let afError = error as? AFError {
guard
case .multipartEncodingFailed = afError,
case .multipartEncodingFailed(let encodingFailure) = afError else {
return false
}

switch encodingFailure {
case .bodyPartFileNotReachableWithError,
.bodyPartFileNotReachable:
return true
default:
return false
}
} else if let nsError = error as NSError?,
if let nsError = error as NSError?,
nsError.domain == multipartEncodingFailedSampleError.domain,
nsError.code == multipartEncodingFailedSampleError.code {
// and if we only have the NSError-level of data, let's just fall back on best-effort guess.
Expand Down