Files weren't deleted from temp unsaved sketch folder. Fixes #4233

This commit is contained in:
Federico Fissore 2015-11-30 10:17:29 +01:00
parent aaebb0a4d6
commit e224698ecf
2 changed files with 3 additions and 3 deletions

View File

@ -463,7 +463,7 @@ public class Sketch {
} else {
// delete the file
if (!current.getCode().deleteFile(BaseNoGui.getBuildFolder(data))) {
if (!current.getCode().deleteFile(BaseNoGui.getBuildFolder(data).toPath(), Paths.get(System.getProperty("java.io.tmpdir"), "arduino_" + DigestUtils.md5Hex(getMainFilePath())))) {
Base.showMessage(tr("Couldn't do it"),
I18n.format(tr("Could not delete \"{0}\"."), current.getCode().getFileName()));
return;

View File

@ -91,12 +91,12 @@ public class SketchCode {
}
protected boolean deleteFile(File tempBuildFolder) throws IOException {
protected boolean deleteFile(Path tempBuildFolder, Path tempUnsavedSketchPath) throws IOException {
if (!file.delete()) {
return false;
}
List<Path> tempBuildFolders = Stream.of(tempBuildFolder.toPath(), Paths.get(tempBuildFolder.getAbsolutePath(), "sketch"))
List<Path> tempBuildFolders = Stream.of(tempBuildFolder, tempBuildFolder.resolve("sketch"), tempUnsavedSketchPath)
.filter(path -> Files.exists(path))
.collect(Collectors.toList());