Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Skip unused broken symlinks#1201

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@matthijskooijman
Copy link
Collaborator

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among thePull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?
    Bug fix
  • What is the current behavior?
  1. When a sketch file (i.e..ino,.cpp, etc.) is unreadable, it is silently skipped when loading the sketch.
  2. When a sketch contains a broken symlink, sketch loading fails even when the file would not be otherwise loaded (i.e. not a.ino,.cpp, etc type of file).
  • What is the new behavior?
  1. When a sketch file (i.e..ino,.cpp, etc.) is unreadable (i.e. no permission or otherwise unreadable), an error is thrown.
  2. When a sketch contains a broken symlink, it is skipped if the file would not be otherwise loaded (i.e. not a.ino,.cpp, etc type of file).
  • Does this PR introduce a breaking change, and is
    titled accordingly?

    Sketches that contain unreadable files that are not actually needed can no longer be compiled (they show an error instead of silently skipping the unreadable file), but I would consider such sketches an unsupported corner case.
  • Other information:
    The trigger for this PR was that I had a symlink in my sketch to thecompile_commands.json in the build folder, so my editor would find that file and use it for code completion. However, after a reboot, the symlink would become broken, andarduino-cli compile (even with--only-compilation-database would fail, requiring me to remove the symlink and then recreate it afterwards.

The first commit was not strictly required for this problem, but it seemed like a good idea to not silently ignore unreadable files, and raising this error simplifies the second commit, while still raising an error as before on symlinks that would be loaded.

I've omitted testcases from this PR, since a significant of the code paths to test would result inos.Exit, which I think is not supported directly in the test framework. Are there any strategies in place for handling this already (seethis post for some suggestions if not)?

@matthijskooijman
Copy link
CollaboratorAuthor

Any chance of merging this? It's a fairly straightforward bugfix :-)

When any sketch file that would normally be compiled is unreadable,SketchLoad would previously just silently skip it, leading topotentially unexpected results. It is probably better to just error outand let the user sort out the problem instead.Additionally, this prepares for improving the handling of brokensymlinks in the next commit.
Previously, SketchLoad would error out on *any* error during fileenumeration, including broken symlinks (where `os.Stat` returns`ErrNotExist`), even when that symlink would not be loaded (i.e. novalid extension) anyway.Now, `ErrNotExist` errors are ignored and a broken symlink is processedas normal. This changes the code to assume broken symlinks are notdirectories and to use the `path` value instead of the `info.Name()`,since the latter is not available when the `Stat()` call failed.If, based on the name of the broken symlink, the file would be skipped,processing continues as normal. If the file would be loaded, then theexisting `os.Open()` call fails (and since the previous commit, returnsan error like before for all broken symlinks).
@matthijskooijmanmatthijskooijmanforce-pushed theskip-unused-broken-symlinks branch fromdadb144 to021b449CompareApril 19, 2021 14:03
@matthijskooijman
Copy link
CollaboratorAuthor

Hm, I just rebased this on top of latest master, and discovered that his fix no longer works entirely as expected due to#1235. That PR added support for .json files, so this means that a broken symlink tocompile_commands.json now again triggers an error. This is because this PR ensures that broken symlinks that would not be loaded as a sketch file at all are ignored, but with#1235compile_commands.json is now a valid sketch file that must be loaded, and thus also reports an error if it is a broken symlink...

I'm not directly sure what a good approach for this is, though. Maybe add an explicit ignore forcompile_commands.json (since I don't think it should be listed as a sketch file in any case), and then also apply the changes in the PR?

@matthijskooijman
Copy link
CollaboratorAuthor

Closing in favor of#1438.

@per1234per1234 added topic: codeRelated to content of the project itself type: imperfectionPerceived defect in any part of project conclusion: duplicateHas already been submitted labelsJun 27, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

conclusion: duplicateHas already been submittedtopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@matthijskooijman@per1234

[8]ページ先頭

©2009-2025 Movatter.jp