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

Ignore cached project roots that point to nonexistent directories. #984

Merged
merged 1 commit into from
Apr 1, 2016

Conversation

Wilfred
Copy link
Contributor

@Wilfred Wilfred commented Mar 22, 2016

This fixes an awkward bug when the current project is a symlink that
changes. Suppose we have the following filesystem layout:

/tmp/projectile_project -> /tmp/first_project

If we now delete /tmp/first_project and change the symlink:

/tmp/projectile_project -> /tmp/second_project

then projectile-project-root-cache will contain a key
"projectile-root-bottom-up-/tmp/projectile-project" with value
"/tmp/first_project". This will stop projectile-find-file from working
as it can't cd to /tmp/first_project.

Instead, we enforce that the string from projectile-project-root
points to a directory that currently exists.

@bbatsov
Copy link
Owner

bbatsov commented Mar 26, 2016

The change looks good. Note it in the changelog and drop the . from the commit's title.

@@ -790,7 +790,7 @@ The current directory is assumed to be the project's root otherwise."
(let ((dir default-directory))
(or (--some (let* ((cache-key (format "%s-%s" it dir))
(cache-value (gethash cache-key projectile-project-root-cache)))
(if cache-value
(if (and cache-value (file-exists-p cache-value))
Copy link
Owner

Choose a reason for hiding this comment

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

Btw, this change might be problematic for tramp users, as such checks are very slow there.

This fixes an awkward bug when the current project is a symlink that
changes. Suppose we have the following filesystem layout:

    /tmp/projectile_project -> /tmp/first_project

If we now delete /tmp/first_project and change the symlink:

    /tmp/projectile_project -> /tmp/second_project

then `projectile-project-root-cache` will contain a key
`"projectile-root-bottom-up-/tmp/projectile-project"` with value
`"/tmp/first_project"`. This will stop `projectile-find-file` from working
as it can't cd to /tmp/first_project.

Instead, we enforce that the string from `projectile-project-root`
points to a directory that currently exists.
@Wilfred
Copy link
Contributor Author

Wilfred commented Mar 26, 2016

@bbatsov thanks, changelog and commit message updated.

@bbatsov bbatsov merged commit d397777 into bbatsov:master Apr 1, 2016
@Wilfred Wilfred deleted the changing_symlinks branch June 30, 2016 14:29
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.

2 participants