summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2018-02-06 11:21:49 -0500
committerGitHub <noreply@github.com>2018-02-06 11:21:49 -0500
commit8975c9654f38552518f608045354209111d39bcf (patch)
treeef4caf7814025ab47995a8764b9af7a321ccf069
parent273a78c419a9a7c77b609fd5617f45b9f078712a (diff)
parentd85cc6297ca432d503139b51e313fedbb68aed9c (diff)
downloadsdl_ios-8975c9654f38552518f608045354209111d39bcf.tar.gz
Merge pull request #853 from smartdevicelink/bugs/issue_827_listfiles_workaround
Fix ListFiles bug on older modules
-rw-r--r--SmartDeviceLink/SDLFileManager.m10
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m8
-rw-r--r--SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testAppAndVehicleIcons@2x.pngbin101989 -> 29249 bytes
-rw-r--r--SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testLightBackgroundNoAppNoVehicleIcons@2x.pngbin43314 -> 29249 bytes
-rw-r--r--SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testNoAppNoVehicleIcons@2x.pngbin46030 -> 29249 bytes
-rw-r--r--SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testOnlyAppIcon@2x.pngbin52927 -> 29249 bytes
-rw-r--r--SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testOnlyVehicleIcon@2x.pngbin56436 -> 29249 bytes
7 files changed, 16 insertions, 2 deletions
diff --git a/SmartDeviceLink/SDLFileManager.m b/SmartDeviceLink/SDLFileManager.m
index 25ec7aec0..8942ec2d7 100644
--- a/SmartDeviceLink/SDLFileManager.m
+++ b/SmartDeviceLink/SDLFileManager.m
@@ -40,12 +40,13 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError";
@property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager;
// Remote state
-@property (strong, nonatomic, readwrite) NSMutableSet<SDLFileName *> *mutableRemoteFileNames;
+@property (strong, nonatomic) NSMutableSet<SDLFileName *> *mutableRemoteFileNames;
@property (assign, nonatomic, readwrite) NSUInteger bytesAvailable;
// Local state
@property (strong, nonatomic) NSOperationQueue *transactionQueue;
@property (strong, nonatomic) NSMutableDictionary<SDLFileName *, NSOperation *> *uploadsInProgress;
+@property (strong, nonatomic) NSMutableSet<SDLFileName *> *uploadedEphemeralFileNames;
@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];
+ _uploadedEphemeralFileNames = [[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.uploadedEphemeralFileNames 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.uploadedEphemeralFileNames addObject:fileName];
}
if (uploadCompletion != nil) {
uploadCompletion(success, bytesAvailable, error);
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
index 355d41273..8a7a0db78 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
@@ -25,6 +25,7 @@ SDLFileManagerState *const SDLFileManagerStateReady = @"Ready";
@interface SDLFileManager ()
@property (strong, nonatomic) NSOperationQueue *transactionQueue;
+@property (strong, nonatomic) NSMutableSet<SDLFileName *> *uploadedEphemeralFileNames;
@end
QuickSpecBegin(SDLFileManagerSpec)
@@ -225,6 +226,7 @@ describe(@"SDLFileManager", ^{
it(@"should set the file manager state to be waiting", ^{
expect(testFileManager.currentState).to(match(SDLFileManagerStateReady));
+ expect(testFileManager.uploadedEphemeralFileNames).to(beEmpty());
});
it(@"should create a putfile with the correct data", ^{
@@ -253,6 +255,7 @@ describe(@"SDLFileManager", ^{
expect(@(testFileManager.bytesAvailable)).toEventually(equal(testResponseBytesAvailable));
expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateReady));
expect(testFileManager.remoteFileNames).toEventually(contain(testFileName));
+ expect(testFileManager.uploadedEphemeralFileNames).toEventually(contain(testFileName));
});
it(@"should call the completion handler with the correct data", ^{
@@ -282,6 +285,7 @@ describe(@"SDLFileManager", ^{
expect(@(testFileManager.bytesAvailable)).toEventually(equal(@(initialSpaceAvailable)));
expect(testFileManager.remoteFileNames).toEventually(contain(testFileName));
expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateReady));
+ expect(testFileManager.uploadedEphemeralFileNames).to(beEmpty());
});
it(@"should call the completion handler with the correct data", ^{
@@ -307,7 +311,7 @@ describe(@"SDLFileManager", ^{
});
});
- context(@"when allow overwrite is false", ^{
+ context(@"when allow overwrite is NO", ^{
__block SDLRPCRequest *lastRequest = nil;
beforeEach(^{
@@ -373,6 +377,7 @@ describe(@"SDLFileManager", ^{
it(@"should set the file manager state correctly", ^{
expect(@(testFileManager.bytesAvailable)).toEventually(equal(testResponseBytesAvailable));
expect(testFileManager.remoteFileNames).toEventually(contain(testFileName));
+ expect(testFileManager.uploadedEphemeralFileNames).toEventually(contain(testUploadFile.name));
expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateReady));
});
@@ -404,6 +409,7 @@ describe(@"SDLFileManager", ^{
it(@"should set the file manager state correctly", ^{
expect(@(testFileManager.bytesAvailable)).toEventually(equal(@(initialSpaceAvailable)));
expect(testFileManager.remoteFileNames).toEventuallyNot(contain(testFileName));
+ expect(testFileManager.uploadedEphemeralFileNames).toEventuallyNot(contain(testUploadFile.name));
expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateReady));
});
diff --git a/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testAppAndVehicleIcons@2x.png b/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testAppAndVehicleIcons@2x.png
index bef5354d6..3648c2bce 100644
--- a/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testAppAndVehicleIcons@2x.png
+++ b/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testAppAndVehicleIcons@2x.png
Binary files differ
diff --git a/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testLightBackgroundNoAppNoVehicleIcons@2x.png b/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testLightBackgroundNoAppNoVehicleIcons@2x.png
index 7c3972fd4..3648c2bce 100644
--- a/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testLightBackgroundNoAppNoVehicleIcons@2x.png
+++ b/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testLightBackgroundNoAppNoVehicleIcons@2x.png
Binary files differ
diff --git a/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testNoAppNoVehicleIcons@2x.png b/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testNoAppNoVehicleIcons@2x.png
index b6bca2f99..3648c2bce 100644
--- a/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testNoAppNoVehicleIcons@2x.png
+++ b/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testNoAppNoVehicleIcons@2x.png
Binary files differ
diff --git a/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testOnlyAppIcon@2x.png b/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testOnlyAppIcon@2x.png
index 2081fcdcc..3648c2bce 100644
--- a/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testOnlyAppIcon@2x.png
+++ b/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testOnlyAppIcon@2x.png
Binary files differ
diff --git a/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testOnlyVehicleIcon@2x.png b/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testOnlyVehicleIcon@2x.png
index d83c4e6dc..3648c2bce 100644
--- a/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testOnlyVehicleIcon@2x.png
+++ b/SmartDeviceLinkTests/ReferenceImages_64/SDLLockScreenViewControllerSnapshotTests/testOnlyVehicleIcon@2x.png
Binary files differ