🐛 fix "share log" error due to leftover loggerDB tmp file #1197
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.
e-mission/e-mission-docs#1110
After sharing the tmp DB file, we try to clear it, but if this operation fails or the app exits before we get to this, for any reason, all subsequent attempts to share the DB file would fail with error 12
PATH_EXISTS_ERR
A simple solution is to attempt to clear the tmp file before and after sharing.
I also changed this to async/await syntax to make it clearer what is happening.
Testing done:
I ran a dev build of emission on an Android test phone. From profile I clicked Share log and saw
tmp file did not exist, that is fine...
in the console.The share menu came up, but before dismissing it I went into app settings and Force Quit the app. This caused a leftover tmp file that was not cleared. (I never saw
Successfully cleaned up file loggerDB
in the console)Then I launched the app again and repeated the same steps. This time I saw
Successfully cleaned up file...
in the console. The user-visible behavior was the same (share menu popped up). This time I allowed the share menu to dismiss and I sawSuccessfully cleaned up file loggerDB
again