-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 pre-allocation when changing priority #7738
Conversation
…ly, to make open_file() work as expected. If there's a failure, restore it
@@ -161,15 +162,22 @@ error_code translate_error(std::error_code const& err, bool const write) | |||
|
|||
download_priority_t const old_prio = m_file_priority[i]; | |||
download_priority_t new_prio = prio[i]; | |||
|
|||
m_file_priority[i] = new_prio; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I'm not a C++ guy, but this looks sketchy to me. Also considering that new_prio
is not const.
Why do we need such intermediate variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not necessary. but I like giving it an intuitive name. it probably should be const
, but it's a copy either way.
while working on a test for this, I realized that the |
Posix storage is not affected because it does not use this pref in the first place, and |
I was wrong. files are actually allocated on non-windows when the sparse flag isn't set. |
I have completely lost the thread of discussion. What do you mean by posix systems? File preallocation does work on Linux (using mmap storage), that's the platform I use and test things on. |
b7aa3d6
to
46e45f3
Compare
ae4003c
to
5c24565
Compare
5c24565
to
74c7c8b
Compare
thanks @HanabishiRecca ! |
based on @HanabishiRecca 's research and fix. set m_file_priority early, to make open_file() work as expected. If there's a failure, restore it.
#7733