Skip to content

Commit 629fdbe

Browse files
committed
Fix symlinks being replaced with files on save
Fixes arduino#5478
1 parent 6b06000 commit 629fdbe

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

app/src/processing/app/Editor.java

+1
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,7 @@ private void resumeOrCloseSerialMonitor() {
22282228
serialMonitor.close();
22292229
handleSerial();
22302230
} else {
2231+
Thread.sleep(200);
22312232
serialMonitor.resume(boardPort);
22322233
}
22332234
}

arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
157157
Thread.sleep(250);
158158
}
159159
} catch (SerialException e) {
160-
throw new RunnerException(e);
160+
throw new RunnerException(e.getMessage());
161161
} catch (InterruptedException e) {
162162
throw new RunnerException(e.getMessage());
163163
} finally {

arduino-core/src/processing/app/BaseNoGui.java

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import java.util.*;
3434
import java.util.logging.Level;
3535
import java.util.logging.Logger;
36+
import java.nio.file.Files;
37+
import java.nio.file.Path;
3638

3739
import cc.arduino.packages.BoardPort;
3840

@@ -1058,6 +1060,10 @@ static public void saveFile(String str, File file) throws IOException {
10581060
File temp = File.createTempFile(file.getName(), null, file.getParentFile());
10591061
PApplet.saveStrings(temp, new String[] { str });
10601062
if (file.exists()) {
1063+
boolean isSymbolicLink = Files.isSymbolicLink(file.toPath());
1064+
if (isSymbolicLink) {
1065+
file = file.toPath().toRealPath().toFile().getAbsoluteFile();
1066+
}
10611067
boolean result = file.delete();
10621068
if (!result) {
10631069
throw new IOException(

0 commit comments

Comments
 (0)