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

extractWithoutRootDirectory() fails if destination is . #22

Open
xabbuh opened this issue May 21, 2015 · 12 comments
Open

extractWithoutRootDirectory() fails if destination is . #22

xabbuh opened this issue May 21, 2015 · 12 comments

Comments

@xabbuh
Copy link
Contributor

xabbuh commented May 21, 2015

If you pass . (the current working directory) as the destination to the Distill::extractWithoutRootDirectory() method, extracting the archive fails with a message like this:

rmdir: failed to remove ‘.’: Invalid argument

The reason for this is, for example, explained here.

@raulfraile
Copy link
Owner

@xabbuh thanks for opening the issue! Working on it...

@xabbuh
Copy link
Contributor Author

xabbuh commented May 21, 2015

@raulfraile Thank you. I thought that calling realpath() on the path that is passed to rmdir() would suffice. However, that led to other issues (probably due to the fact that the current working directory does not exist any more after the removal). Maybe we need to switch the working directory first in those cases.

@raulfraile
Copy link
Owner

@xabbuh yes, I'm working with that approach, the working directory needs to be changed first

@raulfraile
Copy link
Owner

@xabbuh it should be fixed in the fix/current_dir branch. Do you have any comments about eb8fed8?

@xabbuh
Copy link
Contributor Author

xabbuh commented May 21, 2015

@raulfraile Do we need some special handling in case there is no parent directory?

@raulfraile
Copy link
Owner

@xabbuh would that happen only if you are in the root directory or is there any other situation? Anyway, I think we should handle gracefully and throw an error

@xabbuh
Copy link
Contributor Author

xabbuh commented May 21, 2015

I think this will only happen when you are in the root directory.

@xabbuh
Copy link
Contributor Author

xabbuh commented May 21, 2015

@raulfraile The fix does not work as is. I think the issue is the check if ('.' === $path). Imho this needs to be either if ('.' === basename($path) or something like if (getcwd() === realpath($path)).

@raulfraile
Copy link
Owner

@xabbuh thanks for your suggestions! Now I throw an exception when you are in the root directory and I use getcwd() === realpath($path) to check if the target directory is the same as the current directory

@raulfraile
Copy link
Owner

Commit: 5fa7ce1

@xabbuh
Copy link
Contributor Author

xabbuh commented May 21, 2015

@raulfraile I can confirm that this fixes the root issue.

@xabbuh
Copy link
Contributor Author

xabbuh commented May 25, 2015

@raulfraile I see one issue with the proposed solution: When using the Symfony installer, the user would have to change directories after installing Symfony in the current directory because the current working directory does not exist anymore. What do you think about extracting the archive to a temporary subdirectory instead and moving contents up after the extraction succeeded?

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

No branches or pull requests

2 participants