| 25 | } |
| 26 | |
| 27 | void executeImpl(const CommandLineOptions & options, DisksClient & client) override |
| 28 | { |
| 29 | const auto & disk = client.getCurrentDiskWithPath(); |
| 30 | const String & path = disk.getRelativeFromRoot(getValueFromCommandLineOptionsThrow<String>(options, "path")); |
| 31 | bool recursive = options.contains("recursive"); |
| 32 | if (disk.getDisk()->existsDirectory(path)) |
| 33 | { |
| 34 | if (!recursive) |
| 35 | { |
| 36 | throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot remove '{}': Is a directory", path); |
| 37 | } |
| 38 | |
| 39 | LOG_INFO(log, "Removing directory '{}' at disk '{}'", path, disk.getDisk()->getName()); |
| 40 | |
| 41 | disk.getDisk()->removeRecursiveWithLimit(path); |
| 42 | } |
| 43 | else if (disk.getDisk()->existsFile(path)) |
| 44 | { |
| 45 | LOG_INFO(log, "Removing file '{}' at disk '{}'", path, disk.getDisk()->getName()); |
| 46 | disk.getDisk()->removeFileIfExists(path); |
| 47 | } |
| 48 | else |
| 49 | throw Exception(ErrorCodes::BAD_ARGUMENTS, "Path {} on disk {} doesn't exist", path, disk.getDisk()->getName()); |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | CommandPtr makeCommandRemove() |
nothing calls this directly
no test coverage detected