mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 13:25: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:
parent
38bb70f5d0
commit
06e111c229
@ -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
|
||||
|
12
src/bees.cc
12
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()
|
||||
{
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user