fixup! refactor: modernize cache.cc (#3108) (#3715)

This commit is contained in:
Charles Kerr 2022-08-26 14:46:46 -05:00 committed by GitHub
parent a24679d89f
commit 9e07b6f4c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -89,8 +89,14 @@ int Cache::writeContiguous(CIter const begin, CIter const end) const
TR_ASSERT(std::size(buf) == buflen);
// save it
auto* const tor = torrents_.get(begin->key.first);
auto const loc = tor->blockLoc(begin->key.second);
auto const& [torrent_id, block] = begin->key;
auto* const tor = torrents_.get(torrent_id);
if (tor == nullptr)
{
return EINVAL;
}
auto const loc = tor->blockLoc(block);
if (auto const err = tr_ioWrite(tor, loc, std::size(buf), std::data(buf)); err != 0)
{