diff --git a/src/Storages/System/StorageSystemDetachedParts.cpp b/src/Storages/System/StorageSystemDetachedParts.cpp index 980529032c4..11c4f7843ac 100644 --- a/src/Storages/System/StorageSystemDetachedParts.cpp +++ b/src/Storages/System/StorageSystemDetachedParts.cpp @@ -44,19 +44,22 @@ static void calculateTotalSizeOnDiskImpl(const DiskPtr & disk, const String & fr { tryLogCurrentException(__PRETTY_FUNCTION__); } - return; } - std::vector files; - try + else { - disk->listFiles(from, files); + DirectoryIteratorPtr it; + try + { + it = disk->iterateDirectory(from); + } + catch (...) + { + tryLogCurrentException(__PRETTY_FUNCTION__); + } + + for (; it->isValid(); it->next()) + calculateTotalSizeOnDiskImpl(disk, fs::path(from) / it->name(), total_size); } - catch (...) - { - tryLogCurrentException(__PRETTY_FUNCTION__); - } - for (const auto & file : files) - calculateTotalSizeOnDiskImpl(disk, fs::path(from) / file, total_size); } static UInt64 calculateTotalSizeOnDisk(const DiskPtr & disk, const String & from)