Skip to content

Commit

Permalink
fix: delete cached apk files when picking new one (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mipirakas authored Nov 9, 2022
1 parent 2c3809d commit fd5d71e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ui/views/app_selector/app_selector_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';
import 'package:device_apps/device_apps.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/patcher_api.dart';
Expand Down Expand Up @@ -45,6 +46,11 @@ class AppSelectorViewModel extends BaseViewModel {
);
if (result != null && result.files.single.path != null) {
File apkFile = File(result.files.single.path!);
List<String> pathSplit = result.files.single.path!.split("/");
pathSplit.removeLast();
Directory filePickerCacheDir = Directory(pathSplit.join("/"));
Iterable<File> deletableFiles = (await filePickerCacheDir.list().toList()).whereType<File>();
for (var file in deletableFiles) { if (file.path != apkFile.path && file.path.endsWith(".apk")) file.delete(); }
ApplicationWithIcon? application = await DeviceApps.getAppFromStorage(
apkFile.path,
true,
Expand Down

0 comments on commit fd5d71e

Please sign in to comment.