mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
fix: Move temporary files outside of the cache directory (#2193)
Co-authored-by: Pun Butrach <pun.butrach@gmail.com>
This commit is contained in:
parent
d688f38a63
commit
1ef1f8d47a
3 changed files with 13 additions and 1 deletions
|
@ -364,6 +364,9 @@ class MainActivity : FlutterActivity() {
|
||||||
"An error occurred:\n$stack"
|
"An error occurred:\n$stack"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
inFile.delete()
|
||||||
|
tmpDir.deleteRecursively()
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.post { result.success(null) }
|
handler.post { result.success(null) }
|
||||||
|
|
|
@ -34,7 +34,7 @@ class PatcherAPI {
|
||||||
Future<void> initialize() async {
|
Future<void> initialize() async {
|
||||||
await loadPatches();
|
await loadPatches();
|
||||||
await _managerAPI.downloadIntegrations();
|
await _managerAPI.downloadIntegrations();
|
||||||
final Directory appCache = await getTemporaryDirectory();
|
final Directory appCache = await getApplicationSupportDirectory();
|
||||||
_dataDir = await getExternalStorageDirectory() ?? appCache;
|
_dataDir = await getExternalStorageDirectory() ?? appCache;
|
||||||
_tmpDir = Directory('${appCache.path}/patcher');
|
_tmpDir = Directory('${appCache.path}/patcher');
|
||||||
_keyStoreFile = File('${_dataDir.path}/revanced-manager.keystore');
|
_keyStoreFile = File('${_dataDir.path}/revanced-manager.keystore');
|
||||||
|
@ -151,6 +151,7 @@ class PatcherAPI {
|
||||||
String packageName,
|
String packageName,
|
||||||
String apkFilePath,
|
String apkFilePath,
|
||||||
List<Patch> selectedPatches,
|
List<Patch> selectedPatches,
|
||||||
|
bool isFromStorage,
|
||||||
) async {
|
) async {
|
||||||
final File? integrationsFile = await _managerAPI.downloadIntegrations();
|
final File? integrationsFile = await _managerAPI.downloadIntegrations();
|
||||||
final Map<String, Map<String, dynamic>> options = {};
|
final Map<String, Map<String, dynamic>> options = {};
|
||||||
|
@ -176,6 +177,13 @@ class PatcherAPI {
|
||||||
final File inApkFile = File('${workDir.path}/in.apk');
|
final File inApkFile = File('${workDir.path}/in.apk');
|
||||||
await File(apkFilePath).copy(inApkFile.path);
|
await File(apkFilePath).copy(inApkFile.path);
|
||||||
|
|
||||||
|
if (isFromStorage) {
|
||||||
|
// The selected apk was copied to cacheDir by the file picker, so it's not needed anymore.
|
||||||
|
// rename() can't be used here, as Android system also counts the size of files moved out from cacheDir
|
||||||
|
// as part of the app's cache size.
|
||||||
|
File(apkFilePath).delete();
|
||||||
|
}
|
||||||
|
|
||||||
outFile = File('${workDir.path}/out.apk');
|
outFile = File('${workDir.path}/out.apk');
|
||||||
|
|
||||||
final Directory tmpDir =
|
final Directory tmpDir =
|
||||||
|
|
|
@ -188,6 +188,7 @@ class InstallerViewModel extends BaseViewModel {
|
||||||
_app.packageName,
|
_app.packageName,
|
||||||
_app.apkFilePath,
|
_app.apkFilePath,
|
||||||
_patches,
|
_patches,
|
||||||
|
_app.isFromStorage,
|
||||||
);
|
);
|
||||||
_app.appliedPatches = _patches.map((p) => p.name).toList();
|
_app.appliedPatches = _patches.map((p) => p.name).toList();
|
||||||
if (_managerAPI.isLastPatchedAppEnabled()) {
|
if (_managerAPI.isLastPatchedAppEnabled()) {
|
||||||
|
|
Loading…
Reference in a new issue