From ecdc76462314c996373b758da170769524b7f7e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Kunz?= Date: Fri, 19 Apr 2024 11:03:22 +0200 Subject: [PATCH 1/3] KDESKTOP-767 - Handle "not a directory" error --- src/libcommonserver/io/iohelper.cpp | 1 + test/libcommonserver/io/testcheckifpathexists.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/libcommonserver/io/iohelper.cpp b/src/libcommonserver/io/iohelper.cpp index cb8fd8de8..a653afc1a 100644 --- a/src/libcommonserver/io/iohelper.cpp +++ b/src/libcommonserver/io/iohelper.cpp @@ -63,6 +63,7 @@ IoError IoHelper::stdError2ioError(int error) noexcept { case static_cast(std::errc::is_a_directory): return IoErrorIsADirectory; case static_cast(std::errc::no_such_file_or_directory): + case static_cast(std::errc::not_a_directory): // Occurs in particular when converting a bundle into a single file return IoErrorNoSuchFileOrDirectory; case static_cast(std::errc::no_space_on_device): return IoErrorDiskFull; diff --git a/test/libcommonserver/io/testcheckifpathexists.cpp b/test/libcommonserver/io/testcheckifpathexists.cpp index ad1a2636e..25d3e19b6 100644 --- a/test/libcommonserver/io/testcheckifpathexists.cpp +++ b/test/libcommonserver/io/testcheckifpathexists.cpp @@ -454,6 +454,17 @@ void TestIo::testCheckIfPathExistsWithSameNodeIdAllBranches() { _testObj->resetFunctions(); } + + // Checking existence of a subdirectory inside a directory that have been deleted and replaced with a file with the same name + // ex: conversion of a bundle into a single file (macOS) + { + const SyncPath path = _localTestDirPath / "test_pictures/picture-1.jpg/A"; + bool exists = false; + IoError ioError = IoErrorUnknown; + CPPUNIT_ASSERT(_testObj->checkIfPathExists(path, exists, ioError)); + CPPUNIT_ASSERT(!exists); + CPPUNIT_ASSERT(ioError == IoErrorNoSuchFileOrDirectory); + } } From c198a6d02a6f91cbbb7a5822adba5a490c4d2288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Kunz?= Date: Fri, 19 Apr 2024 13:56:22 +0200 Subject: [PATCH 2/3] KDESKTOP-767 - Improve test with CppUnit --- test/libcommonserver/io/testcheckifpathexists.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libcommonserver/io/testcheckifpathexists.cpp b/test/libcommonserver/io/testcheckifpathexists.cpp index 25d3e19b6..2584353ae 100644 --- a/test/libcommonserver/io/testcheckifpathexists.cpp +++ b/test/libcommonserver/io/testcheckifpathexists.cpp @@ -463,7 +463,7 @@ void TestIo::testCheckIfPathExistsWithSameNodeIdAllBranches() { IoError ioError = IoErrorUnknown; CPPUNIT_ASSERT(_testObj->checkIfPathExists(path, exists, ioError)); CPPUNIT_ASSERT(!exists); - CPPUNIT_ASSERT(ioError == IoErrorNoSuchFileOrDirectory); + CPPUNIT_ASSERT_EQUAL(IoErrorAccessDenied, ioError); } } From 8ff0a49ec1710bc0851c63712e5a63b50cf1e6fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Kunz?= Date: Fri, 19 Apr 2024 13:59:01 +0200 Subject: [PATCH 3/3] KDESKTOP-767 - Fix test --- test/libcommonserver/io/testcheckifpathexists.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libcommonserver/io/testcheckifpathexists.cpp b/test/libcommonserver/io/testcheckifpathexists.cpp index 2584353ae..b5d24434d 100644 --- a/test/libcommonserver/io/testcheckifpathexists.cpp +++ b/test/libcommonserver/io/testcheckifpathexists.cpp @@ -463,7 +463,7 @@ void TestIo::testCheckIfPathExistsWithSameNodeIdAllBranches() { IoError ioError = IoErrorUnknown; CPPUNIT_ASSERT(_testObj->checkIfPathExists(path, exists, ioError)); CPPUNIT_ASSERT(!exists); - CPPUNIT_ASSERT_EQUAL(IoErrorAccessDenied, ioError); + CPPUNIT_ASSERT_EQUAL(IoErrorNoSuchFileOrDirectory, ioError); } }