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

[WIP] get: try to remove destination directory before renaming download #162

Closed
wants to merge 1 commit into from
Closed

[WIP] get: try to remove destination directory before renaming download #162

wants to merge 1 commit into from

Conversation

schomatis
Copy link
Collaborator

If the package.json file is missing from an installed package (not very likely) fetch will fail while trying to rename to an existing directory.

rm ~/go/src/gx/ipfs/QmdbxjQWogRCHRaxhhGnYdT1oQJzL9GdqSKzCdqWr85AP2/pubsub/package.json
gx install
# ERROR: [97 / 97 ] parallel fetch: failed to fetch package: QmdbxjQWogRCHRaxhhGnYdT1oQJzL9GdqSKzCdqWr85AP2: rename go/src/gx/ipfs/QmdbxjQWogRCHRaxhhGnYdT1oQJzL9GdqSKzCdqWr85AP2.part go/src/gx/ipfs/QmdbxjQWogRCHRaxhhGnYdT1oQJzL9GdqSKzCdqWr85AP2: file exists
# ERROR: install deps: failed to fetch dependencies

Should a test be added?

@schomatis schomatis closed this Mar 6, 2018
@schomatis schomatis reopened this Mar 6, 2018
@djdv
Copy link
Contributor

djdv commented Mar 12, 2018

@schomatis
I created a similar patch to this #163
It moves the check up so it only tries to remove when proven to exist and also removes an uneeded dependency.

Sorry for the overlap, I came across this independently when I got frustrated with an ambiguous "Access is denied" error. I didn't see this pull request when I started.

I can instigating failure by doing this inside of the go-ipfs repo

gx install --local
git clean -fdx
gx install --local

git clean -fdx was not removing any packages with tests in them which caused the problem when trying to move the temporary to the target.

@whyrusleeping
Copy link
Owner

@schomatis sorry I didnt see this one either. I'm merging @djdv's PR as both of these fixes work, but he points out that go's os package now properly does the rename, we no longer need the gorename package.

thank you for the PR!

@schomatis
Copy link
Collaborator Author

@djdv No problem, I'm closing this PR as I like your solution more, it employs the standard library and handles the existence of the destination in a logically coherent place: next to the original check of FindPackageInDir, even if the Shell().Get() fails (for other reasons) it makes sense that the destination should be removed early in the function.

@schomatis schomatis deleted the fix/get/remove-out-dir branch March 12, 2018 22:51
@schomatis
Copy link
Collaborator Author

Oh, @whyrusleeping already took care of it :)

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.

3 participants