diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2021-09-22 15:11:52 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2021-09-22 15:11:52 -0400 |
commit | 6685595ac5d8db73ccfd64542d8af0df61f95ef2 (patch) | |
tree | 3310d35300bb469ed910be62fddb92bb42182e9e | |
parent | bbe5454aa88168c25fbc956e79832ebc63177330 (diff) | |
download | sdl_ios-bugfix/issue-2034-file-manager-multiple-uploads.tar.gz |
Fix SDLFile equality checkbugfix/issue-2034-file-manager-multiple-uploads
-rw-r--r-- | SmartDeviceLink/public/SDLFile.m | 12 | ||||
-rw-r--r-- | SmartDeviceLink/public/SDLFileManager.m | 2 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m | 4 |
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; |