Skip to content

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

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,7 @@ class ManagerAPI {
File outFile
) async {
deleteLastPatchedApp();
final Directory appCache = await getApplicationSupportDirectory();
app.patchedFilePath =
outFile.copySync('${appCache.path}/lastPatchedApp.apk').path;
app.patchedFilePath = outFile.path;
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When last patched app is enabled, outfile points to application support directory.

app.fileSize = outFile.lengthSync();
await _prefs.setString('lastPatchedApp', json.encode(app.toJson()));
}
Expand Down
7 changes: 6 additions & 1 deletion lib/services/patcher_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ class PatcherAPI {
final File inApkFile = File('${workDir.path}/in.apk');
await File(apkFilePath).copy(inApkFile.path);

outFile = File('${workDir.path}/out.apk');
if (_managerAPI.isLastPatchedAppEnabled()) {
final Directory cacheDir = await getApplicationSupportDirectory();
outFile = File('${cacheDir.path}/out.apk');
} else {
outFile = File('${workDir.path}/out.apk');
}

final Directory tmpDir =
Directory('${workDir.path}/revanced-temporary-files');
Expand Down