refactor
This commit is contained in:
parent
fe0c687f82
commit
5c7a5daf73
@ -68,17 +68,23 @@ open_file::open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
|||||||
throw startup_exception("cannot resume a directory|" + fsi.api_path);
|
throw startup_exception("cannot resume a directory|" + fsi.api_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not fsi.directory) {
|
if (fsi.directory) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nf_ = utils::file::file::open_or_create_file(fsi.source_path,
|
nf_ = utils::file::file::open_or_create_file(fsi.source_path,
|
||||||
provider_.is_read_only());
|
provider_.is_read_only());
|
||||||
set_api_error(*nf_ ? api_error::success : api_error::os_error);
|
set_api_error(*nf_ ? api_error::success : api_error::os_error);
|
||||||
if (get_api_error() == api_error::success) {
|
if (get_api_error() != api_error::success) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (read_state.has_value()) {
|
if (read_state.has_value()) {
|
||||||
read_state_ = read_state.value();
|
read_state_ = read_state.value();
|
||||||
set_modified();
|
set_modified();
|
||||||
} else if (fsi_.size > 0U) {
|
} else if (fsi_.size > 0U) {
|
||||||
read_state_.resize(static_cast<std::size_t>(utils::divide_with_ceiling(
|
read_state_.resize(static_cast<std::size_t>(
|
||||||
fsi_.size, chunk_size)),
|
utils::divide_with_ceiling(fsi_.size, chunk_size)),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
auto file_size = nf_->size();
|
auto file_size = nf_->size();
|
||||||
@ -93,8 +99,6 @@ open_file::open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
|||||||
nf_->close();
|
nf_->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open_file::~open_file() { close(); }
|
open_file::~open_file() { close(); }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user