| 40 | } |
| 41 | |
| 42 | DatabaseFilesystem::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 | |
| 65 | std::string DatabaseFilesystem::getTablePath(const std::string & table_name) const |
| 66 | { |
nothing calls this directly
no test coverage detected