Skip to content
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

fix: Delete cached APK after patching #2331

Merged
merged 3 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 0 additions & 7 deletions lib/services/patcher_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
6 changes: 6 additions & 0 deletions lib/ui/views/installer/installer_viewmodel.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -566,6 +568,10 @@ class InstallerViewModel extends BaseViewModel {
Future<void> 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<PatcherViewModel>().selectedApp = null;
locator<PatcherViewModel>().selectedPatches.clear();
locator<PatcherViewModel>().notifyListeners();
Expand Down