Skip to content

Commit e07bd33

Browse files
authored
Fix recursive remove path (#16923)
1 parent 70ed290 commit e07bd33

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

ydb/public/lib/ydb_cli/commands/ydb_workload.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ void TWorkloadCommandBase::CleanTables(NYdbWorkload::IWorkloadQueryGenerator& wo
391391
auto pathsToDelete = workloadGen.GetCleanPaths();
392392
TRemoveDirectoryRecursiveSettings settings;
393393
settings.NotExistsIsOk(true);
394+
settings.CreateProgressBar(true);
394395
for (const auto& path : pathsToDelete) {
395396
Cout << "Remove path " << path << "..." << Endl;
396397
auto fullPath = config.Database + "/" + path.c_str();

ydb/public/lib/ydb_cli/common/recursive_remove.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -222,38 +222,41 @@ TStatus RemoveDirectoryRecursive(
222222

223223
TStatus RemovePathRecursive(
224224
const TDriver& driver,
225-
const TString& path,
225+
const TSchemeEntry& entry,
226226
const TRemoveDirectoryRecursiveSettings& settings
227227
) {
228228
TSchemeClient schemeClient(driver);
229-
auto entity = schemeClient.DescribePath(path).ExtractValueSync();
230-
if (!entity.IsSuccess()) {
231-
if (settings.NotExistsIsOk_ && entity.GetStatus() == EStatus::SCHEME_ERROR && entity.GetIssues().ToString().find("Path not found") != TString::npos) {
232-
return TStatus(EStatus::SUCCESS, {});
233-
}
234-
return entity;
235-
}
236-
237229
TTableClient tableClient(driver);
238230
TTopicClient topicClient(driver);
239231
NQuery::TQueryClient queryClient(driver);
240232
NCoordination::TClient coordinationClient(driver);
241233
auto remover = NInternal::CreateDefaultRemover(schemeClient, tableClient, topicClient, queryClient, coordinationClient, settings);
242-
return remover(entity.GetEntry());
234+
return remover(entry);
243235
}
244236

245237
TStatus RemovePathRecursive(
246238
const TDriver& driver,
247-
const TSchemeEntry& entry,
239+
const TString& path,
248240
const TRemoveDirectoryRecursiveSettings& settings
249241
) {
250242
TSchemeClient schemeClient(driver);
251-
TTableClient tableClient(driver);
252-
TTopicClient topicClient(driver);
253-
NQuery::TQueryClient queryClient(driver);
254-
NCoordination::TClient coordinationClient(driver);
255-
auto remover = NInternal::CreateDefaultRemover(schemeClient, tableClient, topicClient, queryClient, coordinationClient, settings);
256-
return remover(entry);
243+
const auto entity = schemeClient.DescribePath(path).ExtractValueSync();
244+
if (!entity.IsSuccess()) {
245+
if (settings.NotExistsIsOk_ && entity.GetStatus() == EStatus::SCHEME_ERROR && entity.GetIssues().ToString().find("Path not found") != TString::npos) {
246+
return TStatus(EStatus::SUCCESS, {});
247+
}
248+
return entity;
249+
}
250+
251+
auto entry = entity.GetEntry();
252+
entry.Name = path;
253+
switch (entry.Type) {
254+
case NYdb::NScheme::ESchemeEntryType::ColumnStore:
255+
case NYdb::NScheme::ESchemeEntryType::Directory:
256+
return RemoveDirectoryRecursive(driver, path, settings);
257+
default:
258+
return RemovePathRecursive(driver, entity.GetEntry(), settings);
259+
}
257260
}
258261

259262
namespace NInternal {

ydb/public/lib/ydb_cli/common/recursive_remove.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ TStatus RemovePathRecursive(
4141
const TRemoveDirectoryRecursiveSettings& settings = {}
4242
);
4343

44-
TStatus RemovePathRecursive(
45-
const TDriver& driver,
46-
const NScheme::TSchemeEntry& entry,
47-
const TRemoveDirectoryRecursiveSettings& settings = {}
48-
);
49-
5044
namespace NInternal {
5145

5246
using TRemover = std::function<TStatus(const NScheme::TSchemeEntry&)>;

0 commit comments

Comments
 (0)