From f33c7c197dd9074e7224d43673405a8cd5af8f47 Mon Sep 17 00:00:00 2001 From: CI Bot Date: Wed, 20 Nov 2024 18:15:26 +0000 Subject: [PATCH] Run clang-format --- src/common/file_system/local_file_system.cpp | 4 +--- src/main/database.cpp | 1 - test/c_api/database_test.cpp | 13 ++++++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/common/file_system/local_file_system.cpp b/src/common/file_system/local_file_system.cpp index fc8cb2bb8b..63c8cdd89a 100644 --- a/src/common/file_system/local_file_system.cpp +++ b/src/common/file_system/local_file_system.cpp @@ -253,12 +253,11 @@ bool isSubdirectory(const std::filesystem::path& base, const std::filesystem::pa auto canonicalBase = std::filesystem::canonical(base); auto canonicalSub = std::filesystem::canonical(sub); - std::string relative = std::filesystem::relative(canonicalSub, canonicalBase); // Size check for a "." result. // If the path starts with "..", it's not a subdirectory. return !relative.empty() && !(relative.starts_with("..")); - + } catch (const std::filesystem::filesystem_error& e) { // Handle errors, e.g., if paths don't exist std::cerr << "Filesystem error: " << e.what() << std::endl; @@ -268,7 +267,6 @@ bool isSubdirectory(const std::filesystem::path& base, const std::filesystem::pa return false; } - void LocalFileSystem::removeFileIfExists(const std::string& path) { if (!fileOrPathExists(path)) { return; diff --git a/src/main/database.cpp b/src/main/database.cpp index 2fda1dc6f2..4a63555121 100644 --- a/src/main/database.cpp +++ b/src/main/database.cpp @@ -101,7 +101,6 @@ std::string expandPath(main::ClientContext* context, const std::string& path) { // Normalize the path to resolve '.' and '..' std::filesystem::path normalizedPath = std::filesystem::absolute(fullPath).lexically_normal(); return normalizedPath.string(); - } void Database::initMembers(std::string_view dbPath, construct_bm_func_t initBmFunc) { diff --git a/test/c_api/database_test.cpp b/test/c_api/database_test.cpp index 7e1d8ebb17..d2cdfd8cc3 100644 --- a/test/c_api/database_test.cpp +++ b/test/c_api/database_test.cpp @@ -1,8 +1,8 @@ #include "c_api/kuzu.h" +#include "common/exception/io.h" +#include "common/file_system/virtual_file_system.h" #include "graph_test/api_graph_test.h" #include "gtest/gtest.h" -#include "common/file_system/virtual_file_system.h" -#include "common/exception/io.h" using namespace kuzu::main; using namespace kuzu::testing; @@ -114,7 +114,8 @@ TEST_F(CApiDatabaseTest, VirtualFileSystemDeleteFiles) { vfs.removeFileIfExists("/tmp/test1"); } catch (const kuzu::common::IOException& e) { // Expected behavior - EXPECT_STREQ(e.what(), "IO exception: Error: Path /tmp/test1 is not within the allowed home directory /tmp/dbHome/"); + EXPECT_STREQ(e.what(), "IO exception: Error: Path /tmp/test1 is not within the allowed " + "home directory /tmp/dbHome/"); } vfs.removeFileIfExists("/tmp/dbHome/test1"); @@ -133,7 +134,8 @@ TEST_F(CApiDatabaseTest, VirtualFileSystemDeleteFilesEdge) { std::filesystem::create_directories("/tmp/dbHome/../test2"); std::filesystem::create_directories("/tmp/dbHome/test2"); - std::cout << "Resolved Path: " << std::filesystem::absolute("/tmp/dbHome/../test2") << std::endl; + std::cout << "Resolved Path: " << std::filesystem::absolute("/tmp/dbHome/../test2") + << std::endl; std::cout << "Exists: " << std::filesystem::exists("/tmp/test2") << std::endl; // Attempt to delete files outside the home directory (should error) @@ -141,7 +143,8 @@ TEST_F(CApiDatabaseTest, VirtualFileSystemDeleteFilesEdge) { vfs.removeFileIfExists("/tmp/dbHome/../test2"); } catch (const kuzu::common::IOException& e) { // Expected behavior - EXPECT_STREQ(e.what(), "IO exception: Error: Path /tmp/dbHome/../test2 is not within the allowed home directory /tmp/dbHome/"); + EXPECT_STREQ(e.what(), "IO exception: Error: Path /tmp/dbHome/../test2 is not within the " + "allowed home directory /tmp/dbHome/"); } vfs.removeFileIfExists("/tmp/dbHome/test2");