Explicitly check returned errors.

This commit is contained in:
levlam 2023-09-21 14:47:17 +03:00
parent d0d8d74c3e
commit 11c78406c3
2 changed files with 14 additions and 13 deletions

View File

@ -90,18 +90,19 @@ Result<FileLoader::FileInfo> FileDownloader::init() {
} }
} }
if (need_search_file_ && fd_.empty() && size_ > 0 && encryption_key_.empty() && !remote_.is_web()) { if (need_search_file_ && fd_.empty() && size_ > 0 && encryption_key_.empty() && !remote_.is_web()) {
[&] { auto r_path = search_file(remote_.file_type_, name_, size_);
TRY_RESULT(path, search_file(remote_.file_type_, name_, size_)); if (r_path.is_ok()) {
TRY_RESULT(fd, FileFd::open(path, FileFd::Read)); auto r_fd = FileFd::open(r_path.ok(), FileFd::Read);
LOG(INFO) << "Check hash of local file " << path; if (r_fd.is_ok()) {
path_ = std::move(path); path_ = r_path.move_as_ok();
fd_ = std::move(fd); fd_ = r_fd.move_as_ok();
need_check_ = true; need_check_ = true;
only_check_ = true; only_check_ = true;
part_size = 128 * (1 << 10); part_size = 128 * (1 << 10);
bitmask = Bitmask{Bitmask::Ones{}, (size_ + part_size - 1) / part_size}; bitmask = Bitmask{Bitmask::Ones{}, (size_ + part_size - 1) / part_size};
return Status::OK(); LOG(INFO) << "Check hash of local file " << path_;
}(); }
}
} }
FileInfo res; FileInfo res;

View File

@ -31,7 +31,7 @@ TEST(TQueue, hands) {
auto qid = 12; auto qid = 12;
ASSERT_EQ(true, tqueue->get_head(qid).empty()); ASSERT_EQ(true, tqueue->get_head(qid).empty());
ASSERT_EQ(true, tqueue->get_tail(qid).empty()); ASSERT_EQ(true, tqueue->get_tail(qid).empty());
tqueue->push(qid, "hello", 1, 0, td::TQueue::EventId()); tqueue->push(qid, "hello", 1, 0, td::TQueue::EventId()).ignore();
auto head = tqueue->get_head(qid); auto head = tqueue->get_head(qid);
auto tail = tqueue->get_tail(qid); auto tail = tqueue->get_tail(qid);
ASSERT_EQ(head.next().ok(), tail); ASSERT_EQ(head.next().ok(), tail);