mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-01 14:34:24 +02:00
feat: clean patcher cache folder on init
This commit is contained in:
parent
5c657fbed5
commit
1920221b19
@ -19,12 +19,21 @@ class PatcherAPI {
|
|||||||
);
|
);
|
||||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||||
final RootAPI _rootAPI = RootAPI();
|
final RootAPI _rootAPI = RootAPI();
|
||||||
|
late Directory _tmpDir;
|
||||||
List<Patch> _patches = [];
|
List<Patch> _patches = [];
|
||||||
Directory? _tmpDir;
|
|
||||||
File? _outFile;
|
File? _outFile;
|
||||||
|
|
||||||
Future<void> initialize() async {
|
Future<void> initialize() async {
|
||||||
await _loadPatches();
|
await _loadPatches();
|
||||||
|
Directory appCache = await getTemporaryDirectory();
|
||||||
|
_tmpDir = Directory('${appCache.path}/patcher');
|
||||||
|
cleanPatcher();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cleanPatcher() {
|
||||||
|
if (_tmpDir.existsSync()) {
|
||||||
|
_tmpDir.deleteSync(recursive: true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadPatches() async {
|
Future<void> _loadPatches() async {
|
||||||
@ -111,10 +120,8 @@ class PatcherAPI {
|
|||||||
integrationsFile = await _managerAPI.downloadIntegrations('.apk');
|
integrationsFile = await _managerAPI.downloadIntegrations('.apk');
|
||||||
}
|
}
|
||||||
if (patchBundleFile != null) {
|
if (patchBundleFile != null) {
|
||||||
Directory appCache = await getTemporaryDirectory();
|
_tmpDir.createSync();
|
||||||
_tmpDir = Directory('${appCache.path}/patcher');
|
Directory workDir = _tmpDir.createTempSync('tmp-');
|
||||||
_tmpDir!.createSync();
|
|
||||||
Directory workDir = _tmpDir!.createTempSync('tmp-');
|
|
||||||
File inputFile = File('${workDir.path}/base.apk');
|
File inputFile = File('${workDir.path}/base.apk');
|
||||||
File patchedFile = File('${workDir.path}/patched.apk');
|
File patchedFile = File('${workDir.path}/patched.apk');
|
||||||
_outFile = File('${workDir.path}/out.apk');
|
_outFile = File('${workDir.path}/out.apk');
|
||||||
@ -158,13 +165,6 @@ class PatcherAPI {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanPatcher() {
|
|
||||||
if (_tmpDir != null) {
|
|
||||||
_tmpDir!.deleteSync(recursive: true);
|
|
||||||
_tmpDir = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool sharePatchedFile(String appName, String version) {
|
bool sharePatchedFile(String appName, String version) {
|
||||||
if (_outFile != null) {
|
if (_outFile != null) {
|
||||||
String prefix = appName.toLowerCase().replaceAll(' ', '-');
|
String prefix = appName.toLowerCase().replaceAll(' ', '-');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user