mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-07 23:45:33 +00:00
File cache improvement, deleting old temp files
This commit is contained in:
@@ -78,7 +78,7 @@ public class FolderPreviewPanel extends JPanel {
|
||||
|
||||
public FolderPreviewPanel(final MainPanel mainPanel, List<TreeItem> items) {
|
||||
this.items = items;
|
||||
cachedPreviews = Cache.getInstance(false);
|
||||
cachedPreviews = Cache.getInstance(false,"preview");
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -965,12 +966,41 @@ public class Main {
|
||||
Helper.decompilationErrorAdd = AppStrings.translate(Configuration.autoDeobfuscate.get() ? "deobfuscation.comment.failed" : "deobfuscation.comment.tryenable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear old FFDec/JavactiveX temp files
|
||||
*/
|
||||
private static void clearTemp() {
|
||||
String tempDirPath = System.getProperty("java.io.tmpdir");
|
||||
if (tempDirPath == null) {
|
||||
return;
|
||||
}
|
||||
File tempDir = new File(tempDirPath);
|
||||
if (!tempDir.exists()) {
|
||||
return;
|
||||
}
|
||||
File delFiles[] = tempDir.listFiles(new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.matches("ffdec_cache.*\\.tmp") || name.matches("javactivex_.*\\.exe") || name.matches("temp[0-9]+\\.swf") || name.matches("ffdec_view_.*\\.swf");
|
||||
}
|
||||
});
|
||||
for (File f : delFiles) {
|
||||
try {
|
||||
f.delete();
|
||||
} catch (Exception ex) {
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
clearTemp();
|
||||
String pluginPath = Configuration.pluginPath.get();
|
||||
if (pluginPath != null && !pluginPath.isEmpty()) {
|
||||
try {
|
||||
|
||||
@@ -155,6 +155,21 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
super(JSplitPane.HORIZONTAL_SPLIT);
|
||||
this.mainPanel = mainPanel;
|
||||
this.flashPanel = flashPanel;
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(tempFile!=null){
|
||||
try{
|
||||
tempFile.delete();
|
||||
}catch(Exception ex){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
|
||||
@Override
|
||||
@@ -464,7 +479,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
if (tempFile != null) {
|
||||
tempFile.delete();
|
||||
}
|
||||
tempFile = File.createTempFile("temp", ".swf");
|
||||
tempFile = File.createTempFile("ffdec_view_", ".swf");
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
Color backgroundColor = View.swfBackgroundColor;
|
||||
@@ -937,8 +952,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
tempFile.delete();
|
||||
}
|
||||
try {
|
||||
tempFile = File.createTempFile("temp", ".swf");
|
||||
tempFile.deleteOnExit();
|
||||
tempFile = File.createTempFile("ffdec_view_", ".swf");
|
||||
swf.saveTo(new BufferedOutputStream(new FileOutputStream(tempFile)));
|
||||
flashPanel.displaySWF(tempFile.getAbsolutePath(), backgroundColor, swf.frameRate);
|
||||
} catch (IOException iex) {
|
||||
|
||||
Reference in New Issue
Block a user