Files: fixes

GitOrigin-RevId: 5469a6c26fbb187fd52ddaf1c8bacfae4ddddbe9
This commit is contained in:
Arseny Smirnov 2019-03-10 12:31:24 +11:00
parent 384e96b79e
commit 347a22858c
2 changed files with 7 additions and 3 deletions

View File

@ -35,13 +35,14 @@ void PartsManager::set_streaming_offset(int64 offset) {
};
if (offset < 0 || need_check_ || (!unknown_size_flag_ && get_size() < offset)) {
streaming_offset_ = 0;
LOG(ERROR) << "Ignore streaming_offset (1)";
return;
}
auto part_i = offset / part_size_;
if (part_i >= MAX_PART_COUNT) {
if (use_part_count_limit_ && part_i >= MAX_PART_COUNT) {
streaming_offset_ = 0;
// error?
LOG(ERROR) << "Ignore streaming_offset (2)";
return;
}

View File

@ -30,7 +30,10 @@ class ResourceState {
}
bool update_estimated_limit(int64 extra) {
auto new_estimated_limit = used_ + extra;
// unused() must be positive, i.e. used_ + using_ must be less than limit_
// TODO: use exact intersection between using_ and extra.
auto using_and_extra_intersection = min(using_, extra); // between 0 and min(using_, extra)
auto new_estimated_limit = used_ + using_ + extra - using_and_extra_intersection;
// Use extra extra limit
if (new_estimated_limit < limit_) {