1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-17 21:35:45 +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 BeesRoots::crawl_state_filename() const
{ {
string rv; string rv;
// Legacy filename included UUID
rv += "beescrawl."; rv += "beescrawl.";
rv += m_ctx->root_uuid(); rv += m_ctx->root_uuid();
rv += ".dat"; 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; return rv;
} }
@ -101,6 +110,12 @@ BeesRoots::state_save()
m_crawl_state_file.write(ofs.str()); 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"); BEESNOTE("relocking crawl state");
lock.lock(); lock.lock();
// Not really correct but probably close enough // Not really correct but probably close enough

View File

@ -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)); 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 string
BeesStringFile::read() BeesStringFile::read()
{ {

View File

@ -374,6 +374,8 @@ public:
BeesStringFile(Fd dir_fd, string name, size_t limit = 1024 * 1024); BeesStringFile(Fd dir_fd, string name, size_t limit = 1024 * 1024);
string read(); string read();
void write(string contents); void write(string contents);
void name(const string &new_name);
string name() const;
}; };
class BeesHashTable { class BeesHashTable {