From 56fba25e919a51238d49625bedc0b71e4a8f6514 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Wed, 9 Oct 2019 17:27:17 +0200 Subject: [PATCH] Bug fix 3.5/dont scan recursive for whether dir empty (#10204) * don't scan the specified directory recursively to find out whether its empty, only look at all files directly in it. * Update arangosh/Utils/ManagedDirectory.cpp Co-Authored-By: Jan * implement review --- arangosh/Utils/ManagedDirectory.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arangosh/Utils/ManagedDirectory.cpp b/arangosh/Utils/ManagedDirectory.cpp index efdb927662..130ee4268d 100644 --- a/arangosh/Utils/ManagedDirectory.cpp +++ b/arangosh/Utils/ManagedDirectory.cpp @@ -243,12 +243,8 @@ ManagedDirectory::ManagedDirectory(std::string const& path, bool requireEmpty, b return; } - std::vector files(TRI_FullTreeDirectory(_path.c_str())); - bool isEmpty = (files.size() <= 1); - // TODO: TRI_FullTreeDirectory always returns at least one element ("") - // even if directory is empty? - - if (!isEmpty) { + std::vector files(TRI_FilesDirectory(_path.c_str())); + if (!files.empty()) { // directory exists, has files, and we aren't allowed to overwrite if (requireEmpty) { _status.reset(TRI_ERROR_CANNOT_OVERWRITE_FILE,