This commit is contained in:
@ -358,6 +358,19 @@ auto open_file::native_operation(
|
|||||||
return api_error::download_stopped;
|
return api_error::download_stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (new_file_size > fsi_.size) {
|
||||||
|
auto res =
|
||||||
|
cache_size_mgr::instance().expand(new_file_size - fsi_.size, true);
|
||||||
|
if (res != api_error::success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
} else if (new_file_size < fsi_.size) {
|
||||||
|
auto res = cache_size_mgr::instance().shrink(fsi_.size - new_file_size);
|
||||||
|
if (res != api_error::success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto is_empty_file = new_file_size == 0U;
|
auto is_empty_file = new_file_size == 0U;
|
||||||
auto last_chunk = is_empty_file
|
auto last_chunk = is_empty_file
|
||||||
? std::size_t(0U)
|
? std::size_t(0U)
|
||||||
@ -525,19 +538,6 @@ auto open_file::resize(std::uint64_t new_file_size) -> api_error {
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_file_size > fsi_.size) {
|
|
||||||
auto res =
|
|
||||||
cache_size_mgr::instance().expand(new_file_size - fsi_.size, true);
|
|
||||||
if (res != api_error::success) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
auto res = cache_size_mgr::instance().shrink(fsi_.size - new_file_size);
|
|
||||||
if (res != api_error::success) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return native_operation(
|
return native_operation(
|
||||||
new_file_size, [this, &new_file_size](native_handle) -> api_error {
|
new_file_size, [this, &new_file_size](native_handle) -> api_error {
|
||||||
return nf_->truncate(new_file_size) ? api_error::success
|
return nf_->truncate(new_file_size) ? api_error::success
|
||||||
|
Reference in New Issue
Block a user