diff --git a/src/bees-roots.cc b/src/bees-roots.cc index 8f11570..7ca9b96 100644 --- a/src/bees-roots.cc +++ b/src/bees-roots.cc @@ -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 diff --git a/src/bees.cc b/src/bees.cc index 6f90cad..eba4e5f 100644 --- a/src/bees.cc +++ b/src/bees.cc @@ -351,6 +351,18 @@ BeesStringFile::BeesStringFile(Fd dir_fd, string name, size_t limit) : BEESLOG("BeesStringFile " << name_fd(m_dir_fd) << "/" << m_name << " max size " << pretty(m_limit)); } +void +BeesStringFile::name(const string &new_name) +{ + m_name = new_name; +} + +string +BeesStringFile::name() const +{ + return m_name; +} + string BeesStringFile::read() { diff --git a/src/bees.h b/src/bees.h index cc472ea..9ba080a 100644 --- a/src/bees.h +++ b/src/bees.h @@ -374,6 +374,8 @@ public: BeesStringFile(Fd dir_fd, string name, size_t limit = 1024 * 1024); string read(); void write(string contents); + void name(const string &new_name); + string name() const; }; class BeesHashTable {