mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-13 10:29:35 +01:00
Merge branch 'renaming' of https://github.com/matthijskooijman/Arduino
This commit is contained in:
commit
9e5dc5ce3b
@ -26,7 +26,6 @@ package processing.app;
|
||||
import cc.arduino.Compiler;
|
||||
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;
|
||||
@ -463,7 +462,7 @@ public class Sketch {
|
||||
|
||||
} else {
|
||||
// delete the file
|
||||
if (!current.getCode().deleteFile(BaseNoGui.getBuildFolder(data).toPath(), Paths.get(System.getProperty("java.io.tmpdir"), "arduino_" + DigestUtils.md5Hex(getMainFilePath())))) {
|
||||
if (!current.getCode().deleteFile(BaseNoGui.getBuildFolder(data).toPath())) {
|
||||
Base.showMessage(tr("Couldn't do it"),
|
||||
I18n.format(tr("Could not delete \"{0}\"."), current.getCode().getFileName()));
|
||||
return;
|
||||
@ -1100,17 +1099,27 @@ public class Sketch {
|
||||
|
||||
CompilerProgressListener progressListener = editor.status::progressUpdate;
|
||||
|
||||
boolean deleteTemp = false;
|
||||
String pathToSketch = data.getMainFilePath();
|
||||
if (isModified()) {
|
||||
// If any files are modified, make a copy of the sketch with the changes
|
||||
// saved, so arduino-builder will see the modifications.
|
||||
pathToSketch = saveSketchInTempFolder();
|
||||
deleteTemp = true;
|
||||
}
|
||||
|
||||
return new Compiler(pathToSketch, data, buildPath).build(progressListener, save);
|
||||
try {
|
||||
return new Compiler(pathToSketch, data, buildPath).build(progressListener,
|
||||
save);
|
||||
} finally {
|
||||
// Make sure we clean up any temporary sketch copy
|
||||
if (deleteTemp)
|
||||
FileUtils.recursiveDelete(new File(pathToSketch).getParentFile());
|
||||
}
|
||||
}
|
||||
|
||||
private String saveSketchInTempFolder() throws IOException {
|
||||
File tempFolder = FileUtils.createTempFolder("arduino_", DigestUtils.md5Hex(data.getMainFilePath()));
|
||||
DeleteFilesOnShutdown.add(tempFolder);
|
||||
File tempFolder = FileUtils.createTempFolder("arduino_modified_sketch_");
|
||||
FileUtils.copy(getFolder(), tempFolder);
|
||||
|
||||
for (SketchCode sc : Stream.of(data.getCodes()).filter(SketchCode::isModified).collect(Collectors.toList())) {
|
||||
|
@ -91,14 +91,13 @@ public class SketchCode {
|
||||
}
|
||||
|
||||
|
||||
protected boolean deleteFile(Path tempBuildFolder, Path tempUnsavedSketchPath) throws IOException {
|
||||
protected boolean deleteFile(Path tempBuildFolder) throws IOException {
|
||||
if (!file.delete()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Path> tempBuildFolders = Stream.of(tempBuildFolder, tempBuildFolder.resolve("sketch"), tempUnsavedSketchPath)
|
||||
.filter(path -> Files.exists(path))
|
||||
.collect(Collectors.toList());
|
||||
List<Path> tempBuildFolders = Stream.of(tempBuildFolder, tempBuildFolder.resolve("sketch"))
|
||||
.filter(path -> Files.exists(path)).collect(Collectors.toList());
|
||||
|
||||
for (Path folder : tempBuildFolders) {
|
||||
if (!deleteCompiledFilesFrom(folder)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user