Skip to content

Commit beadf8f

Browse files
Fix renaming of newly added files
Before 72f815b (Refactor file adding and renaming, and save as handling) renaming a file would first save it and then rename it. Since that commit, renaming an unsaved, newly added file would try to rename a non-existing file on disk, causing an error message. This is fixed by only moving the on-disk file if it exists, otherwise just the in-memory filename is updated and the file will be written during the next save. Fixes: #6265
1 parent cd798ab commit beadf8f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private boolean deleteCompiledFilesFrom(Path tempBuildFolder) throws IOException
177177
public void renameTo(String newName) throws IOException {
178178
File newFile = new File(file.getParentFile(), newName);
179179
sketch.checkNewFilename(newFile);
180-
if (file.renameTo(newFile)) {
180+
if (!file.exists() || file.renameTo(newFile)) {
181181
renamedTo(newFile);
182182
} else {
183183
String msg = I18n.format(tr("Failed to rename \"{0}\" to \"{1}\""), file.getName(), newName);

0 commit comments

Comments
 (0)