| 534 | } |
| 535 | |
| 536 | void DatabaseAtomic::beforeLoadingMetadata(ContextMutablePtr /*context*/, LoadingStrictnessLevel mode) |
| 537 | { |
| 538 | auto db_disk = getDisk(); |
| 539 | |
| 540 | if (mode < LoadingStrictnessLevel::FORCE_RESTORE) |
| 541 | return; |
| 542 | |
| 543 | if (!db_disk->isSymlinkSupported()) |
| 544 | return; |
| 545 | |
| 546 | // When `db_disk` is a `DiskLocal` object, `existsDirectory` will return false if the input path is a symlink. |
| 547 | // So we use `existsFileOrDirectory` here to check if the symlink exists. |
| 548 | if (!db_disk->existsFileOrDirectory(path_to_table_symlinks)) |
| 549 | return; |
| 550 | |
| 551 | /// Recreate symlinks to table data dirs in case of force restore, because some of them may be broken |
| 552 | for (const auto it = db_disk->iterateDirectory(path_to_table_symlinks); it->isValid(); it->next()) |
| 553 | { |
| 554 | auto table_path = fs::path(it->path()); |
| 555 | if (table_path.filename().empty()) |
| 556 | table_path = table_path.parent_path(); |
| 557 | if (!db_disk->isSymlink(table_path)) |
| 558 | { |
| 559 | throw Exception( |
| 560 | ErrorCodes::ABORTED, "'{}' is not a symlink. Atomic database should contains only symlinks.", std::string(table_path)); |
| 561 | } |
| 562 | |
| 563 | db_disk->removeFileIfExists(table_path); |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | LoadTaskPtr DatabaseAtomic::startupDatabaseAsync(AsyncLoader & async_loader, LoadJobSet startup_after, LoadingStrictnessLevel mode) |
| 568 | { |
no test coverage detected