Skip to content

Commit 4885a9d

Browse files
authored
Merge pull request #195 from tus/dw/large-upload-crash
Fixed a crash that made large uploads consume way too much memory
2 parents 2b965d9 + 579ed21 commit 4885a9d

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
# 3.3
1+
2+
# 3.4
3+
4+
## Bugfix
5+
- Fixed an issue that prevented TUSKit from uploading large files (2GB+) [#193](https://github.com/tus/TUSKit/issues/193)
6+
7+
# 3.3.0
28

39
## Enhancements
410

511
- Updated documentation around background uploads
612

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

Sources/TUSKit/Tasks/UploadDataTask.swift

+7-5
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ final class UploadDataTask: NSObject, IdentifiableTask {
7676
return
7777
}
7878

79-
let dataToUpload: Data
79+
let dataSize: Int
8080
let file: URL
8181
do {
82-
dataToUpload = try loadData()
82+
let attr = try FileManager.default.attributesOfItem(atPath: metaData.filePath.path)
83+
dataSize = attr[FileAttributeKey.size] as! Int
84+
8385
file = try prepareUploadFile()
8486
} catch let error {
8587
let tusError = TUSClientError.couldNotLoadData(underlyingError: error)
@@ -104,7 +106,7 @@ final class UploadDataTask: NSObject, IdentifiableTask {
104106
sessionTask = task
105107

106108
if #available(iOS 11.0, macOS 10.13, *) {
107-
observeTask(task: task, size: dataToUpload.count)
109+
observeTask(task: task, size: dataSize)
108110
}
109111
}
110112

@@ -190,8 +192,8 @@ final class UploadDataTask: NSObject, IdentifiableTask {
190192
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.
191193
return try fileHandle.readToEnd()
192194
*/
193-
} else { // No range, older versions
194-
data = fileHandle.readDataToEndOfFile()
195+
} else { // No range, we're uploading the file in full so no need to read / recopy
196+
return metaData.filePath
195197
}
196198

197199
return try files.store(data: data, id: metaData.id, preferredFileExtension: "uploadData")

TUSKitExample/TUSKitExample.xcodeproj/project.pbxproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 52;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -545,7 +545,7 @@
545545
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
546546
CODE_SIGN_STYLE = Automatic;
547547
DEVELOPMENT_ASSET_PATHS = "\"TUSKitExample/Preview Content\"";
548-
DEVELOPMENT_TEAM = G43DLT797F;
548+
DEVELOPMENT_TEAM = 4JMM8JMG3H;
549549
ENABLE_PREVIEWS = YES;
550550
INFOPLIST_FILE = TUSKitExample/Info.plist;
551551
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
@@ -567,7 +567,7 @@
567567
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
568568
CODE_SIGN_STYLE = Automatic;
569569
DEVELOPMENT_ASSET_PATHS = "\"TUSKitExample/Preview Content\"";
570-
DEVELOPMENT_TEAM = G43DLT797F;
570+
DEVELOPMENT_TEAM = 4JMM8JMG3H;
571571
ENABLE_PREVIEWS = YES;
572572
INFOPLIST_FILE = TUSKitExample/Info.plist;
573573
IPHONEOS_DEPLOYMENT_TARGET = 14.1;

0 commit comments

Comments
 (0)