Skip to content

Commit 13d1b66

Browse files
daytime-emweb-flow
andauthored
Releases/v0.3.1 (#28)
## Fixes * fix: Manually-paused uploads don't resume again (#27) Co-authored-by: Emily Dixon <edixon@mux.com> Co-authored-by: GitHub <noreply@github.com>
1 parent be70b3d commit 13d1b66

File tree

5 files changed

+13
-19
lines changed

5 files changed

+13
-19
lines changed

Mux-Upload-SDK.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = 'Mux-Upload-SDK'
33
s.module_name = 'MuxUploadSDK'
4-
s.version = '0.3.0'
4+
s.version = '0.3.1'
55
s.summary = 'Upload video to Mux.'
66
s.description = 'A library for uploading video to Mux. Similar to UpChunk, but for iOS.'
77

Sources/MuxUploadSDK/PublicAPI/MuxUpload.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public final class MuxUpload : Hashable, Equatable {
173173
MuxUploadSDK.logger?.warning("start() called but upload is already in progress")
174174
fileWorker?.addDelegate(
175175
withToken: id,
176-
InternalUploaderDelegate { [weak self] state in self?.handleStateUpdate(state) }
176+
InternalUploaderDelegate { [self] state in handleStateUpdate(state) }
177177
)
178178
fileWorker?.start()
179179
return

Sources/MuxUploadSDK/PublicAPI/Version.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public struct Version {
1313
/// Minor version.
1414
public static let minor = 3
1515
/// Revision number.
16-
public static let revision = 0
16+
public static let revision = 1
1717

1818
/// String form of the version number.
1919
public static let versionString = "\(major).\(minor).\(revision)"

Sources/MuxUploadSDK/Upload/ChunkedFileUploader.swift

+8-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class ChunkedFileUploader {
2222
private var currentWorkTask: Task<(), Never>? = nil
2323
private var _currentState: InternalUploadState = .ready
2424
private var overallProgress: Progress = Progress()
25-
private var lastSeenUpdate: InternalUploadState? = nil
2625
private var lastReadCount: UInt64 = 0
2726
private let reporter = Reporter()
2827

@@ -121,20 +120,17 @@ class ChunkedFileUploader {
121120
notifyStateFromWorker(.success(success))
122121
} catch {
123122
file.close()
124-
if let lastUpdate = lastSeenUpdate {
125-
switch lastUpdate {
126-
case .uploading(let update): do {
127-
if lastReadCount > 0 {
128-
lastReadCount = UInt64(update.progress.completedUnitCount)
129-
}
130-
}
131-
default: break
123+
if error is CancellationError {
124+
MuxUploadSDK.logger?.debug("Task finished due to cancellation in state \(String(describing: self.currentState))")
125+
if case let .uploading(update) = self.currentState {
126+
self._currentState = .paused(update)
132127
}
128+
} else {
129+
MuxUploadSDK.logger?.debug("Task finished due to error in state \(String(describing: self.currentState))")
130+
let uploadError = InternalUploaderError(reason: error, lastByte: lastReadCount)
131+
notifyStateFromWorker(.failure(uploadError))
133132
}
134-
let uploadError = InternalUploaderError(reason: error, lastByte: lastReadCount)
135-
notifyStateFromWorker(.failure(uploadError))
136133
}
137-
138134
}
139135
currentWorkTask = task
140136
}

Sources/MuxUploadSDK/Upload/UploadPersistence.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class UploadPersistence {
2727
try remove(entryAtAbsUrl: upload.uploadURL)
2828
}
2929
} catch {
30-
MuxUploadSDK.logger?.critical("Swallowed error writing to UploadPersistence! Error below:\n\(error.localizedDescription)")
30+
// This makes a lot of noise on the emulator, but might be worth logging if you're having issues around here
31+
//MuxUploadSDK.logger?.critical("Swallowed error writing to UploadPersistence! Error below:\n\(error.localizedDescription)")
3132
}
3233
}
3334

@@ -81,8 +82,6 @@ class UploadPersistence {
8182

8283
func maybeOpenCache() throws {
8384
if cache == nil {
84-
MuxUploadSDK.logger?.info("Had to populate write-through cache")
85-
8685
try self.uploadsFile.maybeOpenCache()
8786
self.cache = try uploadsFile.readContents().asDictionary()
8887
try cleanUpOldEntries() // Obligatory
@@ -207,7 +206,6 @@ fileprivate struct UploadsFileImpl : UploadsFile {
207206
func maybeOpenCache() throws {
208207
let dir = fileURL.deletingLastPathComponent()
209208
if !FileManager.default.fileExists(atPath: dir.path) {
210-
MuxUploadSDK.logger?.info("Had to create temp dir")
211209
try FileManager.default.createDirectory(atPath: dir.path, withIntermediateDirectories: true)
212210
}
213211

0 commit comments

Comments
 (0)