-
-
Notifications
You must be signed in to change notification settings - Fork 814
fix: Directly save APK to the cache when saving last patched app #2332
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
base: dev
Are you sure you want to change the base?
Conversation
This should hopefully solve the issue where it can't write the patched app for some reason
This needs to be tested before merging. I can't get the original issue to appear. |
According to the doc, this change should not make a difference: |
Does this fix #2224? If yes, you can send me an APK with the changes and I'll test it |
@validcube, This PR was marked as ready for review yet there's no review. Maybe you can look into this? |
I tested this PR and found two issues
I think randomization doesn't really solve the problem. I found another simple solution, so please check a PR that I will open. EDITED: I finally found a real cause of this issue. I said "once every two times" at first, but this was wrong. Edited. |
if (_managerAPI.isLastPatchedAppEnabled()) { | ||
// Get a random name from temp dir | ||
// This is to avoid overwriting the last patched app | ||
final String randomName = workDir.path.split('/')[workDir.path.split('/').length - 1]; | ||
final Directory cacheDir = await getApplicationSupportDirectory(); | ||
outFile = File('${cacheDir.path}/$randomName.apk'); | ||
} else { | ||
outFile = File('${workDir.path}/out.apk'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change may be reverted according to the comment in #2490. The change above can be kept.
final Directory appCache = await getApplicationSupportDirectory(); | ||
app.patchedFilePath = | ||
outFile.copySync('${appCache.path}/lastPatchedApp.apk').path; | ||
app.patchedFilePath = outFile.path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But outfile is a temporary file that is eventually deleted no?
This should hopefully solve the issue where it can't write the patched app for some reasonInstead of copying the APK from the temp patcher directory after patching is complete, the patcher will just save the APK to the directory to begin with.