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

Removing .partial that causes repeated failure to download a component #1889

Merged
merged 2 commits into from
Nov 3, 2019
Merged

Removing .partial that causes repeated failure to download a component #1889

merged 2 commits into from
Nov 3, 2019

Conversation

Glamhoth
Copy link
Contributor

@Glamhoth Glamhoth commented Jun 5, 2019

Copy link
Contributor

@rbtcollins rbtcollins left a comment

Choose a reason for hiding this comment

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

There is another identical code block later in the same file. I think looking for all the hash mismatch locations and fixing at once is preferrable to ongoing issues.

@kinnison
Copy link
Contributor

@Glamhoth Are you in a position to respond to Robert's comment?

@Glamhoth
Copy link
Contributor Author

Sorry for the delay. I pushed a commit that uses existing clean function. As for hash mismatches I'm not sure what exactly should I be looking for.

src/dist/download.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

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

@rbtcollins Could you comment on what further change it was you referred to in your previous comment? I think something about handling partials elsewhere?

Otherwise, from my perspective, this change looks useful, though I'd like to see a test to demonstrate the codepaths firing.

download/src/lib.rs Outdated Show resolved Hide resolved
src/errors.rs Outdated Show resolved Hide resolved
@Glamhoth
Copy link
Contributor Author

In that case there is only a test left to be written, but for now I have absolutely no idea how to prepare damaged partial file for it.

Quote from @kinnison (so it won't be lost):

Not impossible, but not something I can think more detailed about right now. In brief, I'd, in perhaps cli-v2, have a test case where you need to look at the generated dist files, read the .sha256 for a channel (fr.ex.) write out a partial file in the right place which will be corrupted or somesuch, and then run rustup install $channel checking for the error

@kinnison
Copy link
Contributor

So while I don't have the details to hand... The test case will have created a set of channel data somewhere because that's used to provide a dist server for the test to update from. The trick will be to find that, get the SHA of the channel manifest, and then use that to create a partial file for the channel manifest (since that'd be named after the SHA I think). I will see if I can catch you on Discord to discuss further.

@bors
Copy link
Contributor

bors commented Oct 26, 2019

☔ The latest upstream changes (presumably #2077) made this pull request unmergeable. Please resolve the merge conflicts.

@c3st7n
Copy link

c3st7n commented Oct 28, 2019

I raised a PR against @Glamhoth's branch that I believe adds a test case for the mentioned scenario.

@Glamhoth
Copy link
Contributor Author

I merged @c3st7n PR and rebased my branch onto upstream master to resolve a conflict.

Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

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

The addition of the test is excellent. I've put a couple of comments in-line. If you could please
address those, and then rebase your branch so it doesn't carry fixup commits, this looks very close to mergeable. Once you've done that I'll try and test against the various issues we have raised which might be mitigated by this, before I merge.

tests/dist.rs Outdated
"target hash",
&path.join("dist/2016-02-02/rustc-nightly-x86_64-apple-darwin.tar.gz.sha256"),
)
.unwrap()[..64]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is unusual, I think I'd prefer:

Suggested change
.unwrap()[..64]
.unwrap().trim()

Assuming I've correctly understood the purpose of that [..64]

Copy link

Choose a reason for hiding this comment

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

Turns out the hash file has more just the sha in it:
66d22b7dea5bf8af3295ef13a2ac71abe85e9ad2616eeb22623ca85e6f613ccf *rustc-nightly-x86_64-apple-darwin.tar.gz

We could split the string on whitespace but at the same time we know it is a fixed 64 character string so I'm tempted to leave it as is?

Also, in the actual code where it reads a hash file (src/dist/download.rs - fn download_hash) it just uses a slice too.

Copy link

Choose a reason for hiding this comment

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

Raised MR to glamhoth (https://github.com/Glamhoth/rustup.rs/pull/3) to use a contstant for the slice.

tests/dist.rs Outdated

match *err.kind() {
ErrorKind::ComponentDownloadFailed(_) => (),
_ => panic!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This could at least be:

Suggested change
_ => panic!(),
k @ _ => panic!("Unexpected error: {}", k),

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
_ => panic!(),
e => panic!("{:?}", e),

Copy link

Choose a reason for hiding this comment

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

This was based on how it is done elsewhere in the same file, happy to change but wonder what you think about keeping it consistent with existing tests. Same goes for the other comment regarding use of [..64] instead of .trim().

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd rather see newer tests looking nicer than the older ones. A separate change to make the tests more obvious throughout could be done, though it doesn't belong here.

@kinnison
Copy link
Contributor

Also, welcome back @Glamhoth :-D

@Glamhoth
Copy link
Contributor Author

Glamhoth commented Nov 1, 2019

Merged https://github.com/Glamhoth/rustup.rs/pull/3 and rebased fixup commits

Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

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

This looks good to me. Thank you all for your efforts.

@wang384670111
Copy link

wang384670111 commented Jul 20, 2023

Because the server is full of memory, I solve this problem by cleaning up some temporary files to free up some memory.

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.

7 participants