* commit '2e3746abc7d70dd72f60a7912cd45472f3032acb': Recursively delete directories in handleAftermath().
This commit is contained in:
@@ -68,7 +68,7 @@ public class RecoverySystem {
|
|||||||
/** Send progress to listeners no more often than this (in ms). */
|
/** Send progress to listeners no more often than this (in ms). */
|
||||||
private static final long PUBLISH_PROGRESS_INTERVAL_MS = 500;
|
private static final long PUBLISH_PROGRESS_INTERVAL_MS = 500;
|
||||||
|
|
||||||
/** Used to communicate with recovery. See bootable/recovery/recovery.c. */
|
/** Used to communicate with recovery. See bootable/recovery/recovery.cpp. */
|
||||||
private static File RECOVERY_DIR = new File("/cache/recovery");
|
private static File RECOVERY_DIR = new File("/cache/recovery");
|
||||||
private static File COMMAND_FILE = new File(RECOVERY_DIR, "command");
|
private static File COMMAND_FILE = new File(RECOVERY_DIR, "command");
|
||||||
private static File UNCRYPT_FILE = new File(RECOVERY_DIR, "uncrypt_file");
|
private static File UNCRYPT_FILE = new File(RECOVERY_DIR, "uncrypt_file");
|
||||||
@@ -506,17 +506,31 @@ public class RecoverySystem {
|
|||||||
String[] names = RECOVERY_DIR.list();
|
String[] names = RECOVERY_DIR.list();
|
||||||
for (int i = 0; names != null && i < names.length; i++) {
|
for (int i = 0; names != null && i < names.length; i++) {
|
||||||
if (names[i].startsWith(LAST_PREFIX)) continue;
|
if (names[i].startsWith(LAST_PREFIX)) continue;
|
||||||
File f = new File(RECOVERY_DIR, names[i]);
|
recursiveDelete(new File(RECOVERY_DIR, names[i]));
|
||||||
if (!f.delete()) {
|
|
||||||
Log.e(TAG, "Can't delete: " + f);
|
|
||||||
} else {
|
|
||||||
Log.i(TAG, "Deleted: " + f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internally, delete a given file or directory recursively.
|
||||||
|
*/
|
||||||
|
private static void recursiveDelete(File name) {
|
||||||
|
if (name.isDirectory()) {
|
||||||
|
String[] files = name.list();
|
||||||
|
for (int i = 0; files != null && i < files.length; i++) {
|
||||||
|
File f = new File(name, files[i]);
|
||||||
|
recursiveDelete(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!name.delete()) {
|
||||||
|
Log.e(TAG, "Can't delete: " + name);
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "Deleted: " + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internally, recovery treats each line of the command file as a separate
|
* Internally, recovery treats each line of the command file as a separate
|
||||||
* argv, so we only need to protect against newlines and nulls.
|
* argv, so we only need to protect against newlines and nulls.
|
||||||
|
|||||||
Reference in New Issue
Block a user