MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / DatabaseFilesystem

Method DatabaseFilesystem

src/Databases/DatabaseFilesystem.cpp:42–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42DatabaseFilesystem::DatabaseFilesystem(const String & name_, const String & path_, ContextPtr context_)
43 : IDatabase(name_), WithContext(context_->getGlobalContext()), path(path_), log(getLogger("DatabaseFileSystem(" + name_ + ")"))
44{
45 bool is_local = context_->getApplicationType() == Context::ApplicationType::LOCAL;
46 fs::path user_files_path = is_local ? "" : fs::canonical(getContext()->getUserFilesPath());
47
48 if (fs::path(path).is_relative())
49 {
50 path = user_files_path / path;
51 }
52
53 path = fs::absolute(path).lexically_normal();
54
55 if (!is_local && !pathStartsWith(fs::path(path), user_files_path))
56 {
57 throw Exception(ErrorCodes::BAD_ARGUMENTS,
58 "Path must be inside user-files path: {}", user_files_path.string());
59 }
60
61 if (!fs::exists(path))
62 throw Exception(ErrorCodes::BAD_ARGUMENTS, "Path does not exist: {}", path);
63}
64
65std::string DatabaseFilesystem::getTablePath(const std::string & table_name) const
66{

Callers

nothing calls this directly

Calls 9

pathStartsWithFunction · 0.85
getApplicationTypeMethod · 0.80
getUserFilesPathMethod · 0.80
getLoggerFunction · 0.50
getContextFunction · 0.50
ExceptionClass · 0.50
existsFunction · 0.50
getGlobalContextMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected