Skip to content

Commit

Permalink
Merge pull request #2279 from joto/check-flatnode-format
Browse files Browse the repository at this point in the history
Check flat node file format for forwards compatibility
  • Loading branch information
lonvia authored Jan 2, 2025
2 parents 6a0c731 + b8bb093 commit 9b740c1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/node-persistent-cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ node_persistent_cache::node_persistent_cache(std::string file_name,
}

m_index = std::make_unique<index_t>(m_fd);

// First location must always be the undefined location, otherwise we
// might be looking at a different kind of file. This check here is for
// forwards compatibility. If and when we change the file format, we
// can use the first 8 bytes to differentiate the file format.
auto const loc = get(0);
if (loc.is_defined()) {
throw fmt_error("Not a version 1 flatnode file '{}'", m_file_name);
}
}

node_persistent_cache::~node_persistent_cache() noexcept
Expand Down

0 comments on commit 9b740c1

Please sign in to comment.