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

Made `fs::copy` return the length of the main stream #44895

Merged
merged 1 commit into from Oct 4, 2017

Conversation

Projects
None yet
6 participants
@stephaneyfx
Contributor

stephaneyfx commented Sep 28, 2017

On Windows with the NTFS filesystem, fs::copy would return the sum of the
lengths of all streams, which can be different from the length reported by
metadata and thus confusing for users unaware of this NTFS peculiarity.

This makes fs::copy return the same length metadata reports which is the
value it used to return before PR #26751. Note that alternate streams are still
copied; their length is just not included in the returned value.

This change relies on the assumption that the stream with index 1 is always the
main stream in the CopyFileEx callback. I could not find any official
document confirming this but empirical testing has shown this to be true,
regardless of whether the alternate stream is created before or after the main
stream.

Resolves #44532

Made `fs::copy` return the length of the main stream
On Windows with the NTFS filesystem, `fs::copy` would return the sum of the
lengths of all streams, which can be different from the length reported by
`metadata` and thus confusing for users unaware of this NTFS peculiarity.

This makes `fs::copy` return the same length `metadata` reports which is the
value it used to return before PR #26751. Note that alternate streams are still
copied; their length is just not included in the returned value.

This change relies on the assumption that the stream with index 1 is always the
main stream in the `CopyFileEx` callback. I could not find any official
document confirming this but empirical testing has shown this to be true,
regardless of whether the alternate stream is created before or after the main
stream.

Resolves #44532
@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Sep 28, 2017

Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dtolnay (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Collaborator

rust-highfive commented Sep 28, 2017

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dtolnay (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Oct 2, 2017

Member

review ping @dtolnay! Pinging you on irc too!

Member

carols10cents commented Oct 2, 2017

review ping @dtolnay! Pinging you on irc too!

@dtolnay

This comment has been minimized.

Show comment
Hide comment
@dtolnay
Member

dtolnay commented Oct 3, 2017

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Oct 3, 2017

Contributor

📌 Commit 61c0c9e has been approved by dtolnay

Contributor

bors commented Oct 3, 2017

📌 Commit 61c0c9e has been approved by dtolnay

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Oct 3, 2017

Contributor

⌛️ Testing commit 61c0c9e with merge bd90aa6...

Contributor

bors commented Oct 3, 2017

⌛️ Testing commit 61c0c9e with merge bd90aa6...

bors added a commit that referenced this pull request Oct 3, 2017

Auto merge of #44895 - stephaneyfx:master, r=dtolnay
Made `fs::copy` return the length of the main stream

On Windows with the NTFS filesystem, `fs::copy` would return the sum of the
lengths of all streams, which can be different from the length reported by
`metadata` and thus confusing for users unaware of this NTFS peculiarity.

This makes `fs::copy` return the same length `metadata` reports which is the
value it used to return before PR #26751. Note that alternate streams are still
copied; their length is just not included in the returned value.

This change relies on the assumption that the stream with index 1 is always the
main stream in the `CopyFileEx` callback. I could not find any official
document confirming this but empirical testing has shown this to be true,
regardless of whether the alternate stream is created before or after the main
stream.

Resolves #44532
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Oct 4, 2017

Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: dtolnay
Pushing bd90aa6 to master...

Contributor

bors commented Oct 4, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: dtolnay
Pushing bd90aa6 to master...

@bors bors merged commit 61c0c9e into rust-lang:master Oct 4, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment