- Notifications
You must be signed in to change notification settings - Fork 1.7k
[RTDB] Fix Fatal Exception: FirebaseDatabasePersistenceFailure #15563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
paulb777 wants to merge 7 commits into main Choose a base branch from pb-rtdb-file-protection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+79 −10
Open
Changes from all commits
Commits
Show all changes
7 commits Select commit Hold shift + click to select a range
637b4ea [RTDB] Fix Fatal Exception: FirebaseDatabasePersistenceFailure
paulb777 91f4b09 Fix test for macos
paulb777 c2413f2 review
paulb777 881f605 Merge branch 'main' into pb-rtdb-file-protection
paulb777 5874de7 Review
paulb777 ca661a5 Merge branch 'main' into pb-rtdb-file-protection
ncooke3 f77937e review
ncooke3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -25,8 +25,11 @@ | |
| #import "FirebaseDatabase/Sources/Snapshot/FSnapshotUtilities.h" | ||
| #import "FirebaseDatabase/Tests/Helpers/FTestHelpers.h" | ||
| | ||
| @interface FLevelDBStorageEngineTests : XCTestCase | ||
| @interface FLevelDBStorageEngine (Tests) | ||
| + (void)ensureDir:(NSString *)path markAsDoNotBackup:(BOOL)markAsDoNotBackup; | ||
| @end | ||
| | ||
| @interface FLevelDBStorageEngineTests : XCTestCase | ||
| @end | ||
| | ||
| @implementation FLevelDBStorageEngineTests | ||
| | @@ -685,4 +688,49 @@ - (void)testRemoveTrackedQueryRemovesTrackedQueryKeys { | |
| ([NSSet setWithArray:@[ @"b", @"c" ]])); | ||
| } | ||
| | ||
| - (void)testEnsureDirSetsCorrectFileProtection { | ||
| Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test doesn't do anything on simulator, and I was unsuccessful at testing on a real device (ran into signing issues with CocoaPods and SwiftPM target needs a host app). Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No action needed. | ||
| NSString *testDirName = | ||
| [NSString stringWithFormat:@"fdb_persistence_test_%lu", (unsigned long)arc4random()]; | ||
| NSString *testPath = [NSTemporaryDirectory() stringByAppendingPathComponent:testDirName]; | ||
| NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
| | ||
| // --- Test creation --- | ||
| [fileManager removeItemAtPath:testPath error:nil]; | ||
| [FLevelDBStorageEngine ensureDir:testPath markAsDoNotBackup:NO]; | ||
| | ||
| NSError *error = nil; | ||
| NSDictionary<NSFileAttributeKey, id> *attributes = [fileManager attributesOfItemAtPath:testPath | ||
| error:&error]; | ||
| XCTAssertNil(error, @"Failed to get attributes of directory: %@", error); | ||
| | ||
| #if !TARGET_OS_SIMULATOR | ||
| // On a physical device, file protection should be set. | ||
| XCTAssertEqualObjects(attributes[NSFileProtectionKey], | ||
| NSFileProtectionCompleteUntilFirstUserAuthentication); | ||
| #else | ||
| XCTAssertNil(attributes[NSFileProtectionKey]); | ||
| #endif | ||
| | ||
| // --- Test update on existing directory --- | ||
| #if !TARGET_OS_SIMULATOR | ||
| // This part of the test is only relevant on devices where file protection is supported. | ||
| [fileManager removeItemAtPath:testPath error:nil]; | ||
| NSDictionary *initialAttributes = @{NSFileProtectionKey : NSFileProtectionNone}; | ||
| XCTAssertTrue([fileManager createDirectoryAtPath:testPath | ||
| withIntermediateDirectories:YES | ||
| attributes:initialAttributes | ||
| error:&error], | ||
| @"Failed to create directory for update test: %@", error); | ||
| | ||
| [FLevelDBStorageEngine ensureDir:testPath markAsDoNotBackup:NO]; | ||
| | ||
| attributes = [fileManager attributesOfItemAtPath:testPath error:&error]; | ||
| XCTAssertNil(error, @"Failed to get attributes after update: %@", error); | ||
paulb777 marked this conversation as resolved. Show resolved Hide resolved | ||
| XCTAssertEqualObjects(attributes[NSFileProtectionKey], | ||
| NSFileProtectionCompleteUntilFirstUserAuthentication); | ||
| #endif // !TARGET_OS_SIMULATOR | ||
| | ||
| // Clean up | ||
| [fileManager removeItemAtPath:testPath error:nil]; | ||
| } | ||
| @end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.