From 5cc449d4fbfe8ad51b40e6f0823794f570cdd076 Mon Sep 17 00:00:00 2001 From: Benjamin Halko Date: Sat, 30 Nov 2024 13:52:46 -0800 Subject: [PATCH 1/5] fix: Use cache directory for the last patched app This should hopefully solve the issue where it can't write the patched app for some reason --- lib/services/manager_api.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 511eb44f3e..d8cba6173a 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -367,7 +367,7 @@ class ManagerAPI { File outFile, ) async { deleteLastPatchedApp(); - final Directory appCache = await getApplicationSupportDirectory(); + final Directory appCache = await getApplicationCacheDirectory(); app.patchedFilePath = outFile.copySync('${appCache.path}/lastPatchedApp.apk').path; app.fileSize = outFile.lengthSync(); From 5387fabceea6c15afb64d7509f8c6046acf30589 Mon Sep 17 00:00:00 2001 From: Benjamin Halko Date: Sat, 30 Nov 2024 14:20:06 -0800 Subject: [PATCH 2/5] Use permanent path --- lib/services/manager_api.dart | 4 +--- lib/services/patcher_api.dart | 10 +++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index d8cba6173a..ba3978a4b2 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -367,9 +367,7 @@ class ManagerAPI { File outFile, ) async { deleteLastPatchedApp(); - final Directory appCache = await getApplicationCacheDirectory(); - app.patchedFilePath = - outFile.copySync('${appCache.path}/lastPatchedApp.apk').path; + app.patchedFilePath = outFile.path; app.fileSize = outFile.lengthSync(); await _prefs.setString( 'lastPatchedApp', diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index 6ac47d2f03..b8ef7caf2f 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -182,7 +182,15 @@ class PatcherAPI { File(apkFilePath).delete(); } - outFile = File('${workDir.path}/out.apk'); + 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'); + } final Directory tmpDir = Directory('${workDir.path}/revanced-temporary-files'); From 63f23652a86b7f09962f1187e6366fe5b0e0c33f Mon Sep 17 00:00:00 2001 From: Benjamin Date: Fri, 9 May 2025 09:58:37 -0700 Subject: [PATCH 3/5] Update patcher_api.dart --- lib/services/patcher_api.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index 3fc0ab4e18..f40337e7c2 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -176,7 +176,7 @@ class PatcherAPI { await File(apkFilePath).copy(inApkFile.path); outFile = File('${workDir.path}/out.apk'); - + final Directory tmpDir = Directory('${workDir.path}/revanced-temporary-files'); From 2de57952a0dde830c427f89754959f759971f0ac Mon Sep 17 00:00:00 2001 From: Benjamin Date: Fri, 9 May 2025 10:38:55 -0700 Subject: [PATCH 4/5] Update patcher_api.dart --- lib/services/patcher_api.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index f40337e7c2..282bb60d62 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -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'); From c62650bee9b34187abb07d1f7363465a4ed8dd43 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Fri, 9 May 2025 15:44:38 -0700 Subject: [PATCH 5/5] renamed files dir --- lib/services/patcher_api.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index 282bb60d62..98dcb3f4a3 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -176,8 +176,8 @@ class PatcherAPI { await File(apkFilePath).copy(inApkFile.path); if (_managerAPI.isLastPatchedAppEnabled()) { - final Directory cacheDir = await getApplicationSupportDirectory(); - outFile = File('${cacheDir.path}/out.apk'); + final Directory filesDir = await getApplicationSupportDirectory(); + outFile = File('${filesDir.path}/out.apk'); } else { outFile = File('${workDir.path}/out.apk'); }