Skip to content
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

Fix the app crashing when two folders and their ancestors have the same names #1460

Merged
merged 2 commits into from
Aug 18, 2024

Conversation

aguillon
Copy link
Contributor

Hi!

I think this fixes #1440. As mentioned there, a way to reproduce is to open the folders /usr and $HOME/usr. In this case, the issue is not so much that the two folders and their ancestors have the same names, but that find_unique_path does not handle recursion up to the root.

This is my first contribution to a Vala project, ever. In particular, I don't know how to call a code formatter or how to write unit tests (which would make a lot of sense with the present issue). If you show me how, I will gladly update my PR.

@jeremypw
Copy link
Collaborator

jeremypw commented Aug 11, 2024

@aguillon I use vala-lint to flag up elementaryOS code style issues but no automatic code formatting at the moment. The CI will fail if there are serious code style errors (as it does currently).

You can get the source code of vala-lint from https://github.com/vala-lang/vala-lint.git.

There is code style info on the Developer section of the ElementaryOS website.

The project does not currently implement any unit tests so don't worry about that. You can look at other projects like Files and Terminal for examples of how it is done.

I have quickly tried out your fix and it seems to be working! I'll test it a bit more then it should be good to merge.

Copy link
Collaborator

@jeremypw jeremypw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed a the situation mentioned in the linked issue. As get_parent () can return null I think you need to perform a null check before referencing that parent.

@aguillon aguillon force-pushed the fix-same-name-1440 branch from 5ea3752 to cfabc67 Compare August 12, 2024 14:11
@aguillon aguillon force-pushed the fix-same-name-1440 branch from cfabc67 to a392191 Compare August 12, 2024 14:20
@aguillon
Copy link
Contributor Author

Thank you for vala-lint.

As get_parent () can return null I think you need to perform a null check before referencing that parent.

Thank you, indeed this could happen if we add the root as a project. This should work now.

src/Utils.vala Show resolved Hide resolved
Copy link
Collaborator

@jeremypw jeremypw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets merge this now!

@jeremypw jeremypw enabled auto-merge (squash) August 18, 2024 17:10
@jeremypw jeremypw merged commit 30092fd into elementary:master Aug 18, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opening folders with same name and on different partitions as projects causes Code to crash
2 participants