From 4132eacba0dd58fac7f341f2c407264d27a241bc Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 3 Mar 2018 22:09:05 +0800 Subject: [PATCH] Clear folder if installation failed Close #420 --- .../java/com/topjohnwu/magisk/asyncs/InstallMagisk.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java b/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java index e1d8555eb..2b5925666 100644 --- a/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java +++ b/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java @@ -42,6 +42,7 @@ public class InstallMagisk extends ParallelTask { private List console, logs; private String mBootLocation; private int mode; + private File install; private InstallMagisk(Activity context, List console, List logs, Uri zip) { super(context); @@ -66,10 +67,10 @@ public class InstallMagisk extends ParallelTask { protected Boolean doInBackground(Void... voids) { MagiskManager mm = MagiskManager.get(); - File install = new File( + install = new File( (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? - mm.createDeviceProtectedStorageContext() : - mm).getFilesDir().getParent() + mm.createDeviceProtectedStorageContext() : mm) + .getFilesDir().getParent() , "install"); Shell.Sync.sh("rm -rf " + install); @@ -249,6 +250,7 @@ public class InstallMagisk extends ParallelTask { protected void onPostExecute(Boolean result) { FlashActivity activity = (FlashActivity) getActivity(); if (!result) { + Shell.Async.sh("rm -rf " + install); console.add("! Installation failed"); activity.reboot.setVisibility(View.GONE); }