refactor
This commit is contained in:
@ -122,13 +122,14 @@ open_file::~open_file() { close(); }
|
|||||||
|
|
||||||
auto open_file::adjust_cache_size(std::uint64_t file_size, bool shrink)
|
auto open_file::adjust_cache_size(std::uint64_t file_size, bool shrink)
|
||||||
-> api_error {
|
-> api_error {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
if (file_size == fsi_.size) {
|
if (file_size == fsi_.size) {
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_size > fsi_.size) {
|
if (file_size > fsi_.size) {
|
||||||
auto size = file_size - file_size.value();
|
auto size = file_size - file_size;
|
||||||
auto res = shrink ? cache_size_mgr::instance().shrink(size)
|
auto res = shrink ? cache_size_mgr::instance().shrink(size)
|
||||||
: cache_size_mgr::instance().expand(size);
|
: cache_size_mgr::instance().expand(size);
|
||||||
if (res == api_error::success) {
|
if (res == api_error::success) {
|
||||||
@ -178,7 +179,7 @@ auto open_file::check_allocation() -> api_error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
file_lock.unlock();
|
file_lock.unlock();
|
||||||
res = adjust_cache_size(file_size.value(), true);
|
auto res = adjust_cache_size(file_size.value(), true);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user