mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
Faster recompilation of unsaved sketches
This commit is contained in:
parent
f906d45de0
commit
682a5ec331
@ -28,6 +28,7 @@ import cc.arduino.CompilerProgressListener;
|
||||
import cc.arduino.UploaderUtils;
|
||||
import cc.arduino.files.DeleteFilesOnShutdown;
|
||||
import cc.arduino.packages.Uploader;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import processing.app.debug.RunnerException;
|
||||
import processing.app.forms.PasswordAuthorizationDialog;
|
||||
import processing.app.helpers.FileUtils;
|
||||
@ -1130,7 +1131,7 @@ public class Sketch {
|
||||
}
|
||||
|
||||
private String saveSketchInTempFolder() throws IOException {
|
||||
File tempFolder = FileUtils.createTempFolder();
|
||||
File tempFolder = FileUtils.createTempFolder("arduino_", DigestUtils.md5Hex(data.getMainFilePath()));
|
||||
DeleteFilesOnShutdown.add(tempFolder);
|
||||
FileUtils.copy(getFolder(), tempFolder);
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class LibraryInstaller {
|
||||
progress.setStatus(I18n.format(tr("Installing library: {0}"), lib.getName()));
|
||||
progressListener.onProgress(progress);
|
||||
File libsFolder = indexer.getSketchbookLibrariesFolder();
|
||||
File tmpFolder = FileUtils.createTempFolderIn(libsFolder);
|
||||
File tmpFolder = FileUtils.createTempFolder(libsFolder);
|
||||
try {
|
||||
new ArchiveExtractor(platform).extract(lib.getDownloadedFile(), tmpFolder, 1);
|
||||
} catch (Exception e) {
|
||||
|
@ -3,6 +3,8 @@ package processing.app.helpers;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -84,15 +86,27 @@ public class FileUtils {
|
||||
}
|
||||
|
||||
public static File createTempFolder() throws IOException {
|
||||
return createTempFolderIn(new File(System.getProperty("java.io.tmpdir")));
|
||||
return createTempFolder(new File(System.getProperty("java.io.tmpdir")));
|
||||
}
|
||||
|
||||
public static File createTempFolderIn(File parent) throws IOException {
|
||||
File tmpFolder = new File(parent, "arduino_" + new Random().nextInt(1000000));
|
||||
if (!tmpFolder.mkdir()) {
|
||||
throw new IOException("Unable to create temp folder " + tmpFolder);
|
||||
}
|
||||
return tmpFolder;
|
||||
public static File createTempFolder(File parent) throws IOException {
|
||||
return createTempFolder(parent, "arduino_");
|
||||
}
|
||||
|
||||
public static File createTempFolder(File parent, String prefix) throws IOException {
|
||||
return createTempFolder(parent, prefix, Integer.toString(new Random().nextInt(1000000)));
|
||||
}
|
||||
|
||||
public static File createTempFolder(String prefix) throws IOException {
|
||||
return createTempFolder(new File(System.getProperty("java.io.tmpdir")), prefix);
|
||||
}
|
||||
|
||||
public static File createTempFolder(String prefix, String suffix) throws IOException {
|
||||
return createTempFolder(new File(System.getProperty("java.io.tmpdir")), prefix, suffix);
|
||||
}
|
||||
|
||||
public static File createTempFolder(File parent, String prefix, String suffix) throws IOException {
|
||||
return Files.createDirectories(Paths.get(parent.getAbsolutePath(), prefix + suffix)).toFile();
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user