Skip to content

Naming collision during "Save As" causes overwrite of secondary sketch file #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
per1234 opened this issue Feb 11, 2022 · 0 comments · Fixed by #2292
Closed
3 tasks done

Naming collision during "Save As" causes overwrite of secondary sketch file #827

per1234 opened this issue Feb 11, 2022 · 0 comments · Fixed by #2292
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Feb 11, 2022

Describe the problem

The name of the primary source file of a sketch must match the sketch folder. For this reason, the IDE's "Save As..." function does two things:

  • Saves the sketch files to a folder of the selected name (e.g., FooSketch).
  • Renames the primary source file to match the new sketch name (e.g., FooSketch.ino).

This introduces the possibility of a collision between the target primary source file name and existing secondary source files of the sketch.

🙂 When such a collision occurs while using Arduino IDE 1.x, the operation is halted and the problem clearly communicated to the user:

image

🐛 When such a collision occurs while using Arduino IDE 2.x, the secondary source file is silently overwritten.

To reproduce

  1. Select File > New from the Arduino IDE menus.
  2. Click the button on the right side of the editor tabs bar.
  3. Select "New Tab" from the menu.
  4. Create a tab named Foo.ino
  5. Add some unique content to the tab:
    // Foo.ino tab content
  6. Select File > Save As... from the Arduino IDE menus.
  7. Save the sketch as Foo

🐛 The sketch now contains only a single file Foo.ino, with the contents from the primary source file. The previous contents of the Foo.ino secondary source file have been lost.

Expected behavior

  1. Halt the operation that would result in data loss.
  2. Clearly communicate the problem to the user.

-OR-

  1. Request confirmation from the user before overwriting the file.

Arduino IDE version

Original report

2.0.0-rc3-snapshot.69ac1f4

Last verified with

9a6a457

Operating system

Windows

Operating system version

11

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Feb 11, 2022
@kittaakos kittaakos assigned kittaakos and unassigned AlbyIanna Nov 23, 2023
@kittaakos kittaakos mentioned this issue Nov 23, 2023
4 tasks
kittaakos pushed a commit that referenced this issue Jan 15, 2024
The Save As operation is halted and the problem clearly communicated to
the user when there is a collision between the target primary source
file name and existing secondary source files of the sketch.

Closes #827

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
@kittaakos kittaakos added the conclusion: resolved Issue was resolved label Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants