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 bug when cargo-contract installation had been interrupted #571

Merged
merged 6 commits into from
May 19, 2022

Conversation

cmichi
Copy link
Collaborator

@cmichi cmichi commented May 19, 2022

Fixes #513.

If the crate installation had been interrupted the file _Cargo.toml had already been renamed to Cargo.toml. If the installation was resumed the _Cargo.toml was no longer found. This resulted in the panic Failed renaming _Cargo.toml to Cargo.toml: File not found..

I fixed it by copy (with overwrite) the file _Cargo.toml to Cargo.toml instead.

@cmichi cmichi requested a review from athei May 19, 2022 07:08
@athei
Copy link
Contributor

athei commented May 19, 2022

Without suggesting that you should do that here (but it wouldn't be too hard): A more elegant solution would use a guard type that does the cleanup on Drop. This will be safe against panics. The current code leaves the Cargo.toml in the directory on panic. Not optimal.

Copy link
Contributor

@athei athei left a comment

Choose a reason for hiding this comment

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

This is fine. But you could be a total champ and put the type into a private sub module and do the copy/rename in the constructor in order to have proper RAII. We don't need the copy and stick with rename in this case even.

build.rs Outdated Show resolved Hide resolved
@cmichi cmichi merged commit 7793ec2 into master May 19, 2022
@cmichi cmichi deleted the cmichi-fix-dirty-directory branch May 19, 2022 15:32
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.

Interrupting installation leaves inconsistent state and if resumed fails
2 participants