diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index 6ac47d2f..f40337e7 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -175,13 +175,6 @@ class PatcherAPI { final File inApkFile = File('${workDir.path}/in.apk'); 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'); final Directory tmpDir = diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 65cbf513..7e7cfdcf 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -1,4 +1,6 @@ // ignore_for_file: use_build_context_synchronously +import 'dart:io'; + import 'package:device_apps/device_apps.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -566,6 +568,10 @@ class InstallerViewModel extends BaseViewModel { Future cleanPatcher() async { try { _patcherAPI.cleanPatcher(); + if (_app.isFromStorage) { + // The selected apk was copied to cacheDir by the file picker, so it's not needed anymore. + File(_app.apkFilePath).delete(); + } locator().selectedApp = null; locator().selectedPatches.clear(); locator().notifyListeners();