1
0
mirror of https://github.com/Zygo/bees.git synced 2025-07-02 08:42:27 +02:00

crawl: remove UUID from file names

Unfortunately we don't get to remove the libuuid dependency because
we still want to read a file that exists in the legacy location.
This commit is contained in:
Zygo Blaxell
2016-12-01 22:07:39 -05:00
parent 38bb70f5d0
commit 06e111c229
3 changed files with 29 additions and 0 deletions

View File

@ -50,9 +50,18 @@ string
BeesRoots::crawl_state_filename() const
{
string rv;
// Legacy filename included UUID
rv += "beescrawl.";
rv += m_ctx->root_uuid();
rv += ".dat";
struct stat buf;
if (fstatat(m_ctx->home_fd(), rv.c_str(), &buf, AT_SYMLINK_NOFOLLOW)) {
// Use new filename
rv = "beescrawl.dat";
}
return rv;
}
@ -101,6 +110,12 @@ BeesRoots::state_save()
m_crawl_state_file.write(ofs.str());
// Renaming things is hard after release
if (m_crawl_state_file.name() != "beescrawl.dat") {
renameat(m_ctx->home_fd(), m_crawl_state_file.name().c_str(), m_ctx->home_fd(), "beescrawl.dat");
m_crawl_state_file.name("beescrawl.dat");
}
BEESNOTE("relocking crawl state");
lock.lock();
// Not really correct but probably close enough