diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2018-01-29 11:45:14 -0500 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2018-01-29 11:45:14 -0500 |
commit | 2cc91686b3b0a319508438fbaec14c2d51974e03 (patch) | |
tree | e07c7bd4fcd0225c019ed5e679ac8cd0dbb7c35d | |
parent | 882aa24b31f92119f600a8fdc0b50dca7dec1d71 (diff) | |
download | sdl_ios-2cc91686b3b0a319508438fbaec14c2d51974e03.tar.gz |
Fix #827
* Set overwrite to true on uploading ephemeral files that have not been uploaded during this session
-rw-r--r-- | SmartDeviceLink/SDLFileManager.m | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/SmartDeviceLink/SDLFileManager.m b/SmartDeviceLink/SDLFileManager.m index 25ec7aec0..d7675496e 100644 --- a/SmartDeviceLink/SDLFileManager.m +++ b/SmartDeviceLink/SDLFileManager.m @@ -46,6 +46,7 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError"; // Local state @property (strong, nonatomic) NSOperationQueue *transactionQueue; @property (strong, nonatomic) NSMutableDictionary<SDLFileName *, NSOperation *> *uploadsInProgress; +@property (strong, nonatomic) NSMutableSet<SDLFileName *> *localUploadedFileNames; @property (strong, nonatomic) SDLStateMachine *stateMachine; @property (copy, nonatomic, nullable) SDLFileManagerStartupCompletionHandler startupCompletionHandler; @@ -71,6 +72,7 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError"; _transactionQueue.name = @"SDLFileManager Transaction Queue"; _transactionQueue.maxConcurrentOperationCount = 1; _uploadsInProgress = [[NSMutableDictionary alloc] init]; + _localUploadedFileNames = [[NSMutableSet<SDLFileName *> alloc] init]; _stateMachine = [[SDLStateMachine alloc] initWithTarget:self initialState:SDLFileManagerStateShutdown states:[self.class sdl_stateTransitionDictionary]]; @@ -272,6 +274,11 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError"; for(SDLFile *file in files) { dispatch_group_enter(uploadFilesTask); + // HAX: [#827](https://github.com/smartdevicelink/sdl_ios/issues/827) Older versions of Core had a bug where list files would cache incorrectly. This led to attempted uploads failing due to the system thinking they were already there when they were not. + if (!file.persistent && [self.remoteFileNames containsObject:file.name] && ![self.localUploadedFileNames containsObject:file.name]) { + file.overwrite = true; + } + [self uploadFile:file completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { if(!success) { failedUploads[file.name] = error; @@ -383,6 +390,7 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError"; } if (success) { [weakSelf.mutableRemoteFileNames addObject:fileName]; + [weakSelf.localUploadedFileNames addObject:fileName]; } if (uploadCompletion != nil) { uploadCompletion(success, bytesAvailable, error); |