Startup cleanup, part 1

This commit is contained in:
Henrik Rydgård
2025-03-26 09:24:14 +01:00
parent 3880f83e81
commit 05b1cf3b80
6 changed files with 29 additions and 69 deletions
+6 -17
View File
@@ -273,19 +273,19 @@ std::string MetaFileSystem::NormalizePrefix(std::string prefix) const {
void MetaFileSystem::Mount(const std::string &prefix, std::shared_ptr<IFileSystem> system) {
std::lock_guard<std::recursive_mutex> guard(lock);
MountPoint x;
x.prefix = prefix;
x.system = system;
for (auto &it : fileSystems) {
if (it.prefix == prefix) {
// Overwrite the old mount. Don't create a new one.
it = x;
// Overwrite the old mount.
// shared_ptr makes sure there's no leak.
it.system = system;
return;
}
}
// Prefix not yet mounted, do so.
MountPoint x;
x.prefix = prefix;
x.system = system;
fileSystems.push_back(x);
}
@@ -305,17 +305,6 @@ void MetaFileSystem::Unmount(const std::string &prefix) {
}
}
bool MetaFileSystem::Remount(const std::string &prefix, std::shared_ptr<IFileSystem> system) {
std::lock_guard<std::recursive_mutex> guard(lock);
for (auto &it : fileSystems) {
if (it.prefix == prefix) {
it.system = system;
return true;
}
}
return false;
}
IFileSystem *MetaFileSystem::GetSystemFromFilename(const std::string &filename) {
size_t prefixPos = filename.find(':');
if (prefixPos == filename.npos)