From f02bdb8fbba25a0db0042dbbf69e0ab529ac3224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sat, 26 Mar 2016 21:10:06 -0700 Subject: [osx] Fixed build error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed an incomplete variable renaming. Don’t bother creating intermediate directories to the legacy cache path. When the main bundle lacks a bundle identifier, as is the case when the SDK runs in the test bundle, fall back on the SDK’s bundle. --- platform/darwin/src/MGLOfflineStorage.mm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'platform/darwin/src/MGLOfflineStorage.mm') diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm index 4555f03001..619e4ce1ab 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -48,8 +48,12 @@ NSString * const MGLOfflinePackMaximumCountUserInfoKey = @"MaximumCount"; appropriateForURL:nil create:YES error:nil]; - cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent: - [NSBundle mainBundle].bundleIdentifier]; + NSString *bundleIdentifier = [NSBundle mainBundle].bundleIdentifier; + if (!bundleIdentifier) { + // There’s no main bundle identifier when running in a unit test bundle. + bundleIdentifier = [NSBundle bundleForClass:[self class]].bundleIdentifier; + } + cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier]; [[NSFileManager defaultManager] createDirectoryAtURL:cacheDirectoryURL withIntermediateDirectories:YES attributes:nil @@ -74,15 +78,10 @@ NSString * const MGLOfflinePackMaximumCountUserInfoKey = @"MaximumCount"; NSURL *legacyCacheDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil - create:YES + create:NO error:nil]; - legacyCacheDirectoryURL = [legacyCacheDirectoryURL URLByAppendingPathComponent: - [NSBundle mainBundle].bundleIdentifier]; - [[NSFileManager defaultManager] createDirectoryAtURL:legacyCacheDirectoryURL - withIntermediateDirectories:YES - attributes:nil - error:nil]; - NSURL *legacyCacheURL = [legacyCacheDirectoryURL URLByAppendingPathComponent:MGLOfflineStorageLegacyFileName]; + legacyCacheDirectoryURL = [legacyCacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier]; + NSURL *legacyCacheURL = [legacyCacheDirectoryURL URLByAppendingPathComponent:MGLOfflineStorageFileName3_2_0_beta_1]; NSString *legacyCachePath = legacyCacheURL ? legacyCacheURL.path : @""; #endif if (![[NSFileManager defaultManager] fileExistsAtPath:cachePath]) { -- cgit v1.2.1