Validate datastore directory #7452
Closed
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.
The provided log points to a java.io.IOException with the message "Unable to create parent directories," which is the root cause of the crash.
This particular error occurred in the host process app and was triggered by a failure to create the necessary directory structure for a Jetpack DataStore file. The file path in question is in the internal directory $filesDir/datastore/aqs/sessionConfigsDataStore.data.version.
This check fails and throws an exception
The proposed fix is not suitable because there is a file called aqs which supposed to be the parent directory of our datastore:
Possible fix: Make AQS manually handle creating the parent directories for DataStore before initializing the two DataStores in https://github.com/firebase/firebase-android-sdk/blob/main/firebase-sessions/src/main/kotlin/com/google/firebase/sessions/FirebaseSessionsComponent.kt#L125
Proposal:
Change directory folder name from $filesDir/datastore/aqs/ to something more oriented to firebase like $filesDir/datastore/firebase-aqs. This will reset values to default
Remove aqs from the DataSore file structure: $filesDir/datastore/sessionConfigsDataStore.data.version. This will reset values to default
Validate that the aqs file does not exist before initializing the two DataStores, throw and exception for host app.