From 88bc3995e0509a3c67074a90dfc6cb52c9a15cb5 Mon Sep 17 00:00:00 2001 From: Anton Ivashkin Date: Thu, 8 Jul 2021 17:41:18 +0300 Subject: [PATCH 1/2] Fix throwing exception when iterate over non existing remote directory --- src/Disks/IDiskRemote.cpp | 6 +++++- src/Disks/IDiskRemote.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Disks/IDiskRemote.cpp b/src/Disks/IDiskRemote.cpp index b30e9613ed8..f4c207d9cbd 100644 --- a/src/Disks/IDiskRemote.cpp +++ b/src/Disks/IDiskRemote.cpp @@ -417,7 +417,11 @@ void IDiskRemote::removeDirectory(const String & path) DiskDirectoryIteratorPtr IDiskRemote::iterateDirectory(const String & path) { - return std::make_unique(metadata_path + path, path); + String meta_path = metadata_path + path; + if (fs::exists(meta_path) && fs::is_directory(meta_path)) + return std::make_unique(meta_path, path); + else + return std::make_unique(); } diff --git a/src/Disks/IDiskRemote.h b/src/Disks/IDiskRemote.h index e725e0ed744..360d4e2de33 100644 --- a/src/Disks/IDiskRemote.h +++ b/src/Disks/IDiskRemote.h @@ -193,6 +193,7 @@ struct IDiskRemote::Metadata class RemoteDiskDirectoryIterator final : public IDiskDirectoryIterator { public: + RemoteDiskDirectoryIterator() {} RemoteDiskDirectoryIterator(const String & full_path, const String & folder_path_) : iter(full_path), folder_path(folder_path_) {} void next() override { ++iter; } From ac68d5ea7130429fad3b6fda62021bd8e3ab79b2 Mon Sep 17 00:00:00 2001 From: Anton Ivashkin Date: Thu, 8 Jul 2021 18:39:41 +0300 Subject: [PATCH 2/2] Fix path concatenation --- src/Disks/IDiskRemote.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Disks/IDiskRemote.cpp b/src/Disks/IDiskRemote.cpp index f4c207d9cbd..a4dcc8037bc 100644 --- a/src/Disks/IDiskRemote.cpp +++ b/src/Disks/IDiskRemote.cpp @@ -417,7 +417,7 @@ void IDiskRemote::removeDirectory(const String & path) DiskDirectoryIteratorPtr IDiskRemote::iterateDirectory(const String & path) { - String meta_path = metadata_path + path; + fs::path meta_path = fs::path(metadata_path) / path; if (fs::exists(meta_path) && fs::is_directory(meta_path)) return std::make_unique(meta_path, path); else