Skip to content

Commit

Permalink
Merge pull request #195 from tus/dw/large-upload-crash
Browse files Browse the repository at this point in the history
Fixed a crash that made large uploads consume way too much memory
  • Loading branch information
donnywals authored Oct 3, 2024
2 parents 2b965d9 + 579ed21 commit 4885a9d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# 3.3

# 3.4

## Bugfix
- Fixed an issue that prevented TUSKit from uploading large files (2GB+) [#193](https://github.com/tus/TUSKit/issues/193)

# 3.3.0

## Enhancements

- Updated documentation around background uploads

## Bugfix
- Fixed an issu with macOS not having a correct path when resuming uploads. Thanks, [@MartinLau7](https://github.com/MartinLau7)
- Fixed an issue with macOS not having a correct path when resuming uploads. Thanks, [@MartinLau7](https://github.com/MartinLau7)
- Fixed a metadta issue on iOS. Thanks, [@MartinLau7](https://github.com/MartinLau7)
- Fixed some issues with metadata not alwasy being cleaned up properly for all platforms. Thanks, [@MartinLau7](https://github.com/MartinLau7)

Expand Down
12 changes: 7 additions & 5 deletions Sources/TUSKit/Tasks/UploadDataTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ final class UploadDataTask: NSObject, IdentifiableTask {
return
}

let dataToUpload: Data
let dataSize: Int
let file: URL
do {
dataToUpload = try loadData()
let attr = try FileManager.default.attributesOfItem(atPath: metaData.filePath.path)
dataSize = attr[FileAttributeKey.size] as! Int

file = try prepareUploadFile()
} catch let error {
let tusError = TUSClientError.couldNotLoadData(underlyingError: error)
Expand All @@ -104,7 +106,7 @@ final class UploadDataTask: NSObject, IdentifiableTask {
sessionTask = task

if #available(iOS 11.0, macOS 10.13, *) {
observeTask(task: task, size: dataToUpload.count)
observeTask(task: task, size: dataSize)
}
}

Expand Down Expand Up @@ -190,8 +192,8 @@ final class UploadDataTask: NSObject, IdentifiableTask {
Note that compiler and api says that readToEnd is available on macOS 10.15.4 and higher, but yet github actions of 10.15.7 fails to find the member.
return try fileHandle.readToEnd()
*/
} else { // No range, older versions
data = fileHandle.readDataToEndOfFile()
} else { // No range, we're uploading the file in full so no need to read / recopy
return metaData.filePath
}

return try files.store(data: data, id: metaData.id, preferredFileExtension: "uploadData")
Expand Down
6 changes: 3 additions & 3 deletions TUSKitExample/TUSKitExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -545,7 +545,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"TUSKitExample/Preview Content\"";
DEVELOPMENT_TEAM = G43DLT797F;
DEVELOPMENT_TEAM = 4JMM8JMG3H;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = TUSKitExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
Expand All @@ -567,7 +567,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"TUSKitExample/Preview Content\"";
DEVELOPMENT_TEAM = G43DLT797F;
DEVELOPMENT_TEAM = 4JMM8JMG3H;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = TUSKitExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
Expand Down

0 comments on commit 4885a9d

Please sign in to comment.