summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2021-09-22 15:11:52 -0400
committerJoel Fischer <joeljfischer@gmail.com>2021-09-22 15:11:52 -0400
commit6685595ac5d8db73ccfd64542d8af0df61f95ef2 (patch)
tree3310d35300bb469ed910be62fddb92bb42182e9e
parentbbe5454aa88168c25fbc956e79832ebc63177330 (diff)
downloadsdl_ios-bugfix/issue-2034-file-manager-multiple-uploads.tar.gz
-rw-r--r--SmartDeviceLink/public/SDLFile.m12
-rw-r--r--SmartDeviceLink/public/SDLFileManager.m2
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m4
3 files changed, 13 insertions, 5 deletions
diff --git a/SmartDeviceLink/public/SDLFile.m b/SmartDeviceLink/public/SDLFile.m
index 89b8042b4..424e7c3b3 100644
--- a/SmartDeviceLink/public/SDLFile.m
+++ b/SmartDeviceLink/public/SDLFile.m
@@ -168,7 +168,7 @@ NS_ASSUME_NONNULL_BEGIN
fileCopy.persistent = _persistent;
fileCopy.isStaticIcon = _isStaticIcon;
- if (_data.length == 0 && _fileURL != nil) {
+ if (_data.length != 0) {
fileCopy.data = _data.copy;
}
@@ -197,9 +197,17 @@ NS_ASSUME_NONNULL_BEGIN
if (!file) { return NO; }
BOOL haveEqualNames = [self.name isEqualToString:file.name];
- BOOL haveEqualData = [self.data isEqualToData:file.data];
BOOL haveEqualFormats = [self.fileType isEqualToEnum:file.fileType];
+ BOOL haveEqualData = NO;
+ if (self.data.length == 0 && file.data.length == 0) {
+ haveEqualData = [self.fileURL isEqual:file.fileURL];
+ } else if (self.data.length > 0 && file.data.length > 0) {
+ haveEqualData = [self.data isEqualToData:file.data];
+ } else {
+ return NO;
+ }
+
return haveEqualNames && haveEqualData && haveEqualFormats;
}
diff --git a/SmartDeviceLink/public/SDLFileManager.m b/SmartDeviceLink/public/SDLFileManager.m
index 38d63ec2c..dfac0361d 100644
--- a/SmartDeviceLink/public/SDLFileManager.m
+++ b/SmartDeviceLink/public/SDLFileManager.m
@@ -333,7 +333,7 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError";
dispatch_group_enter(uploadFilesTask);
__weak typeof(self) weakself = self;
[self uploadFile:file completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) {
- if(!success) {
+ if (!success) {
failedUploads[file.name] = error;
}
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
index 4f556b1b6..782bc090d 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
@@ -1134,7 +1134,7 @@ describe(@"uploading/deleting multiple files in the file manager", ^{
});
it(@"should cancel the remaining files if cancel is triggered after first upload", ^{
- for(int i = 0; i < 5; i += 1) {
+ for(int i = 0; i < 5; i++) {
NSString *testFileName = [NSString stringWithFormat:@"TestSmallFilesMemory%d", i];
SDLFile *testSDLFile = [SDLFile fileWithData:[@"someTextData" dataUsingEncoding:NSUTF8StringEncoding] name:testFileName fileExtension:@"bin"];
testSDLFile.overwrite = true;
@@ -1171,7 +1171,7 @@ describe(@"uploading/deleting multiple files in the file manager", ^{
});
it(@"should cancel the remaining files if cancel is triggered after half of the files are uploaded", ^{
- for(int i = 0; i < 5; i += 1) {
+ for(int i = 0; i < 5; i++) {
NSString *testFileName = [NSString stringWithFormat:@"TestSmallFilesMemory%d", i];
SDLFile *testSDLFile = [SDLFile fileWithData:[@"someTextData" dataUsingEncoding:NSUTF8StringEncoding] name:testFileName fileExtension:@"bin"];
testSDLFile.overwrite = true;