mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Fix out of bound error in disk web
This commit is contained in:
parent
5ded0005a3
commit
37f5c445b4
@ -162,7 +162,22 @@ bool WebObjectStorage::exists(const std::string & path) const
|
||||
|
||||
if (startsWith(it->first, path)
|
||||
|| (it != files.begin() && startsWith(std::prev(it)->first, path)))
|
||||
{
|
||||
shared_lock.unlock();
|
||||
std::unique_lock unique_lock(metadata_mutex);
|
||||
|
||||
/// The code relies on invariant that if this function returned true
|
||||
/// the file exists in files.
|
||||
/// In this case we have a directory which doesn't explicitly exists (like store/xxx/yyy)
|
||||
/// ^^^^^
|
||||
/// Adding it to the files
|
||||
files.emplace(std::make_pair(path, FileData({.type = FileType::Directory})));
|
||||
|
||||
unique_lock.unlock();
|
||||
shared_lock.lock();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user