mirror of
https://github.com/skylot/jadx.git
synced 2024-11-26 22:20:50 +00:00
fix: clear temp root dir instead delete (#2312)
This commit is contained in:
parent
8a34d973ff
commit
3d5e225274
@ -178,7 +178,7 @@ public final class JadxDecompiler implements Closeable {
|
||||
closeInputs();
|
||||
closeLoaders();
|
||||
args.close();
|
||||
FileUtils.deleteTempRootDir();
|
||||
FileUtils.clearTempRootDir();
|
||||
}
|
||||
|
||||
private void closeInputs() {
|
||||
|
@ -152,7 +152,7 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static final SimpleFileVisitor<Path> FILE_DELETE_VISITOR = new SimpleFileVisitor<Path>() {
|
||||
private static final SimpleFileVisitor<Path> FILE_DELETE_VISITOR = new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
Files.delete(file);
|
||||
@ -174,8 +174,30 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteTempRootDir() {
|
||||
deleteDirIfExists(tempRootDir);
|
||||
public static void clearTempRootDir() {
|
||||
clearDir(tempRootDir);
|
||||
}
|
||||
|
||||
public static void clearDir(Path clearDir) {
|
||||
try {
|
||||
Files.walkFileTree(clearDir, Collections.emptySet(), Integer.MAX_VALUE, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
Files.delete(file);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
|
||||
if (!dir.equals(clearDir)) {
|
||||
Files.delete(dir);
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
throw new JadxRuntimeException("Failed to clear directory " + clearDir, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Path createTempDir(String prefix) {
|
||||
|
Loading…
Reference in New Issue
Block a user