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

Delete symlink and active workdir on prune #39

Merged
merged 1 commit into from
Jun 11, 2019
Merged

Delete symlink and active workdir on prune #39

merged 1 commit into from
Jun 11, 2019

Conversation

dpordomingo
Copy link
Contributor

caused by #38

prune command was deleting .env, docker-compose.yml and __active__ symlink,
but not the active workdir itself.

UnsetActive must work with Lstat to check symlink status, instead of accessing the pointed dir.
Prune command must use the real workdir path, instead of the symlink route.

@dpordomingo dpordomingo added the bug Something isn't working label Jun 11, 2019
@dpordomingo dpordomingo self-assigned this Jun 11, 2019
@@ -134,7 +134,7 @@ func UnsetActive() error {
return err
}

_, err = os.Stat(dir)
_, err = os.Lstat(dir)
Copy link
Contributor

Choose a reason for hiding this comment

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

could you explain why do you need to use Lstat here?

Copy link
Contributor Author

@dpordomingo dpordomingo Jun 11, 2019

Choose a reason for hiding this comment

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

sure!

from the PR description:

UnsetActive must work with Lstat to check symlink status,
instead of accessing the pointed dir.

From the function docs:

// UnsetActive removes symlink for active workdir

So let's consider:

__active__ -> ~/.sourced/workdirs/this/dir/was/deleted

Then os.Stat(dir) is going to return os.ErrNotExist (because it checks the pointed file, not the symlink itself), so os.Remove(dir) is not going to be called, so __active__ is not going to be deleted.

Using os.Lstat(dir) it will check the symlink itself (__active__), that exists, so it will be deleted as expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense 👍

Bug fixed: prune command was deleting .env, docker-compose.yml and symlink,
but not the active workdir itself.
UnsetActive must work with Lstat to check symlink status, instead of accessing
the pointed dir.
Prune command must use the real workdir path, instead of the symlink route.

Signed-off-by: David Pordomingo <[email protected]>
@dpordomingo dpordomingo merged commit 967cc1c into src-d:master Jun 11, 2019
@dpordomingo dpordomingo deleted the fix-prune branch June 11, 2019 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants