Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios] Set backup exclusion flag after initializing DefaultFileSource #5124

Merged
merged 3 commits into from
May 25, 2016

Conversation

friedbunny
Copy link
Contributor

@friedbunny friedbunny commented May 24, 2016

Speculatively fixes #5112, where apps mistakenly backup the offline/ambient cache.

This moves the backup exclusion flag to a point just after DefaultFileSource has been created/initialized, ensuring that this flag is set on every launch.

As with the other offline storage tests, the new -testBackupExclusion must be run in alphabetical order — or, at least after the cache has been initialized. The cache file will persist in the simulator when you run these tests locally.

/cc @1ec5

Speculative fix for App Store apps backing-up the offline/ambient cache.
@friedbunny friedbunny added bug iOS Mapbox Maps SDK for iOS offline labels May 24, 2016
@friedbunny friedbunny added this to the ios-v3.3.0 milestone May 24, 2016
@friedbunny friedbunny self-assigned this May 24, 2016
[cacheURL getResourceValue:&exclusionFlag
forKey:NSURLIsExcludedFromBackupKey
error:&error];
XCTAssertTrue([exclusionFlag boolValue], @"Backup exclusion flag should be set for cache database.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: check for nil before downcasting to a BOOL. Either would be a failure in this case, but this is a reminder in case we’ve made a similar assumption elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which would be the runtime behavior when exclusionFlag == nil?

(lldb) po [exclusionFlag boolValue]
<nil>

(lldb) p [exclusionFlag boolValue]
(BOOL) $2 = NO

nil, no?

Copy link
Contributor

@1ec5 1ec5 May 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When exclusionFlag is nil, [exclusionFlag boolValue] is NO, just as if exclusionFlag had been equal to @NO. By invoking the po command, you’re treating the BOOL as an object pointer and attempting to print its -description, which is nil. If we ever have to test that a boolValue is NO, either in tests or in production code, be sure to distinguish between nil and @NO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an extra check that exclusionFlag exists in 6becc07.

NSNumber could be fed some non-value that it then coerces into a
boolean.
@friedbunny friedbunny merged commit 9c91405 into master May 25, 2016
@friedbunny friedbunny deleted the fb-more-backup-exclusion-5112 branch May 25, 2016 02:00
1ec5 added a commit that referenced this pull request Jun 3, 2016
Added entries to the iOS SDK changelog for #5124, #2444, #5141, #5164. Removed entries for changes made since the last release; they go in the GitHub prerelease notes but not here in this document.
1ec5 added a commit that referenced this pull request Jun 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS offline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MGLOfflineStorage iCloud Backup
2 participants