Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kdesktop 1359 vfs functions should return an exit info #404

Merged
merged 133 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
433af19
Convert return type of Vfs::start and Vfs::startImpl from bool to Exi…
herve-er Nov 22, 2024
4886cdb
Remove unused Vfs::isHydrating.
herve-er Nov 22, 2024
30d3eb0
Convert return type of Vfs::updateMetadata and from bool to ExitInfo.
herve-er Nov 22, 2024
8338aec
Convert return type of Vfs::updateMetadata and from bool to ExitInfo …
herve-er Nov 22, 2024
de04c2d
Fix log.
herve-er Nov 25, 2024
bb03a34
Convert return type of Vfs::createPlaceholder from bool to ExitInfo.
herve-er Nov 25, 2024
39dc17f
Convert return type of Vfs::createPlaceholder from bool to ExitInfo. 2
herve-er Nov 25, 2024
f823148
Convert return type of Vfs::convertToPlaceHolder from bool to ExitInfo.
herve-er Nov 25, 2024
c46ab58
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Nov 25, 2024
50210bd
Convert return type of Vfs::convertToPlaceHolder from bool to ExitInf…
herve-er Nov 25, 2024
98e4908
Merge branch 'KDESKTOP-1359-Vfs-functions-should-return-an-ExitInfo' …
herve-er Nov 25, 2024
8126145
Remove unused Vfs::needsMetadataUpdate.
herve-er Nov 25, 2024
d5dea10
Fix file access typo.
herve-er Nov 25, 2024
cac7627
Convert return type of Vfs::updateFetchStatus from bool to ExitInfo.
herve-er Nov 25, 2024
4e62c48
Fix call to getXAttrValue.
herve-er Nov 25, 2024
159ec24
Fix tests.
herve-er Nov 25, 2024
93ad883
Fix liteSyncconnector.mm
herve-er Nov 25, 2024
865fc21
Fixe tests.
herve-er Nov 25, 2024
2b8706e
fix vfs_mac
herve-er Nov 25, 2024
3ef5927
Convert return type of Vfs::forceStatus from bool to ExitInfo.
herve-er Nov 25, 2024
6133157
Revert macOS change
herve-er Nov 25, 2024
6b1b8f4
Convert return type of Vfs::setPinstate from bool to ExitInfo.
herve-er Nov 25, 2024
02d62cd
Convert return type of Vfs::Status from bool to ExitInfo.
herve-er Nov 25, 2024
8ea1990
Fusion
herve-er Nov 26, 2024
89a8c0a
Convert setThumbnail & setAppExcludeList & getFetchingAppList return …
herve-er Nov 26, 2024
1c08e10
Continue the propagation of ExitInfo and add comment on possible Exit…
herve-er Nov 28, 2024
8cea04c
Add VfsWinExitInfo
herve-er Nov 29, 2024
fb6d0af
Revert "Add VfsWinExitInfo"
herve-er Nov 29, 2024
c9d275d
Add NotFound and FileAccessError in vfsWin.
herve-er Nov 29, 2024
5a20598
Fix comments.
herve-er Dec 3, 2024
67bec39
Return ExitCode::LogicError in case of missing vfsCallBack.
herve-er Dec 3, 2024
c91bcce
Correct handling of vfs error
herve-er Dec 4, 2024
d14c3ee
Remove a log
herve-er Dec 4, 2024
b1dada9
Implement source location and add it to ExitInfo.
herve-er Dec 4, 2024
fd972b3
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Dec 4, 2024
bacd051
Fix wrong if condition
herve-er Dec 4, 2024
627049f
Merge branch 'KDESKTOP-1359-Vfs-functions-should-return-an-ExitInfo' …
herve-er Dec 4, 2024
1b2c274
Edit print format of SourceLocation.
herve-er Dec 4, 2024
61b7948
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Dec 5, 2024
f5b1e13
Fix buid.
herve-er Dec 9, 2024
c7159c4
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Dec 9, 2024
143be6f
Fix a LOG macro.
herve-er Dec 9, 2024
7dfe630
Merge branch 'KDESKTOP-1359-Vfs-functions-should-return-an-ExitInfo' …
herve-er Dec 9, 2024
eda5917
Use SourceLocation for Vfs::handleVfsError
herve-er Dec 9, 2024
6d7219d
ExitInfo in vfs_mac
herve-er Dec 9, 2024
5db6b9f
Fx build.
herve-er Dec 9, 2024
9b61586
Fix macOS build.
herve-er Dec 9, 2024
21b30dc
Fix macOS build.
herve-er Dec 9, 2024
dd589cb
Fix macOS test.
herve-er Dec 9, 2024
96a4b45
Fix vfs_mac build.
herve-er Dec 9, 2024
ad94069
Sonar issue.
herve-er Dec 9, 2024
6019442
fix mac build.
herve-er Dec 9, 2024
9bc7ead
Missing QStr2Path
herve-er Dec 9, 2024
3b06f33
Fix testSourceLocation
herve-er Dec 9, 2024
d160e46
Fix TestExecutorWorker::testIsValidDestination
herve-er Dec 9, 2024
30108bf
More useful insight in case of test faillure.
herve-er Dec 9, 2024
2bedb3c
Fix tests
herve-er Dec 10, 2024
2d0fc28
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Dec 10, 2024
582d0cf
Sonar issue part 1
herve-er Dec 10, 2024
226b373
Merge branch 'KDESKTOP-1359-Vfs-functions-should-return-an-ExitInfo' …
herve-er Dec 10, 2024
9a2674b
Sonar issues part 2
herve-er Dec 10, 2024
f27705a
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Dec 10, 2024
d42b92a
Catch SystemError FileAlreadyExists.
herve-er Dec 10, 2024
030b85c
Merge branch 'KDESKTOP-1359-Vfs-functions-should-return-an-ExitInfo' …
herve-er Dec 10, 2024
d7c77eb
Fix build
herve-er Dec 10, 2024
405f623
Fix handleExecutorError switch
herve-er Dec 10, 2024
fde6b46
Remove duplicated line.
herve-er Dec 10, 2024
2462afa
Revert "Remove duplicated line."
herve-er Dec 10, 2024
d4e7ff0
Remove duplicated line.
herve-er Dec 10, 2024
173e527
Reduce code duplication.
herve-er Dec 10, 2024
5a93804
Reduce code duplication.
herve-er Dec 10, 2024
a8eacbd
Fusion.
herve-er Dec 10, 2024
6bbd21b
Reduce code duplication
herve-er Dec 11, 2024
bf2c7f0
Self reveiw.
herve-er Dec 11, 2024
ac4daaf
Remove vfs callback in appserver.
herve-er Dec 11, 2024
bd9abee
Replace QString with SyncPath in VFS function signatures.
herve-er Dec 12, 2024
4101d24
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Dec 12, 2024
0273c0d
Fix Sonar issue
herve-er Dec 12, 2024
e07fa27
Merge branch 'KDESKTOP-1359-Vfs-functions-should-return-an-ExitInfo' …
herve-er Dec 12, 2024
3368732
Fix macOs test
herve-er Dec 12, 2024
7e1ed53
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Dec 12, 2024
d8750cd
Fix macOs test
herve-er Dec 12, 2024
529b11a
Merge branch 'KDESKTOP-1359-Vfs-functions-should-return-an-ExitInfo' …
herve-er Dec 12, 2024
64b4aaa
Fix cmakes.
herve-er Dec 12, 2024
5fbccd9
Remove commented code.
herve-er Dec 12, 2024
74b7ca4
Fix vfs_mac.cpp
herve-er Dec 12, 2024
1e9a8c0
Fix vfs_mac.cpp
herve-er Dec 12, 2024
c12d432
Remove unused variables.
herve-er Dec 12, 2024
b54fd59
Solve conflict.
herve-er Dec 20, 2024
4300ab7
Merge conflict.
herve-er Dec 20, 2024
e62e234
Remove a sub test in testIsValidDestination as it is now impossible t…
herve-er Dec 20, 2024
27865e1
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Jan 3, 2025
692a689
Fix develop merge.
herve-er Jan 3, 2025
f1afeb5
Fix merge.
herve-er Jan 3, 2025
588f4d1
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Jan 8, 2025
3e21b3b
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Jan 10, 2025
8647461
Conflict fix
herve-er Jan 21, 2025
0ccc99f
Self review.
herve-er Jan 22, 2025
234befe
Fix currentLocCompatibility.
herve-er Jan 22, 2025
27e0bcf
Fix a call to _syncFileStatus
herve-er Jan 22, 2025
e82899b
Avoid conversion ambiguity in vfs_mac
herve-er Jan 22, 2025
13d0b3d
Fix a log.
herve-er Jan 22, 2025
d048889
Fix a build error in vfs_mac
herve-er Jan 22, 2025
1dc1e15
Force stop hydration worker in WorkerInfo::~WorkerInfo
herve-er Jan 22, 2025
8d3b3c0
Adress Sonar issue.
herve-er Jan 23, 2025
82e9c0f
Fix a log.
herve-er Jan 23, 2025
6538316
Fix a SyncPath to QString conversion
herve-er Jan 23, 2025
81e17fa
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Jan 23, 2025
2874e44
Fix useless argument copy in some Vfs method.
herve-er Jan 24, 2025
81f53af
Rename Vfs::checkIfPathExist to Vfs::checkIfPathIsValid
herve-er Jan 24, 2025
be00e64
Move WorkerInfo destructor to the header.
herve-er Jan 24, 2025
9ff76cf
Use SyncPath instead of QString in Vfshydrate/dehydrate.
herve-er Jan 24, 2025
7cef8e4
Move WorkerInfo and VfsWorker to dedicated files.
herve-er Jan 24, 2025
4b165ce
Invalidate snapshot in case of FileNotFound error in the executor.
herve-er Jan 24, 2025
cf469a3
Fix inadvertently broken test
herve-er Jan 24, 2025
4420d7f
Merge branch 'KDESKTOP-1359-Vfs-functions-should-return-an-ExitInfo' …
herve-er Jan 24, 2025
54de840
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Jan 24, 2025
e8a37d5
initialize a bool.
herve-er Jan 24, 2025
0ca69da
Merge branch 'KDESKTOP-1359-Vfs-functions-should-return-an-ExitInfo' …
herve-er Jan 24, 2025
4f790d6
Fix a typo.
herve-er Jan 24, 2025
aad8175
Fix a typo.
herve-er Jan 24, 2025
91d30a5
Fix macOS build.
herve-er Jan 24, 2025
0a27b9f
Remove unused parms in Vfs::isDehydratedPlaceholder declaration.
herve-er Jan 24, 2025
b6e7721
Move vfs_win/vfs_mac in libcommonserver.
herve-er Jan 24, 2025
6fd6859
Change broken include.
herve-er Jan 24, 2025
1added2
Fix some broken include.
herve-er Jan 24, 2025
2489ae3
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Jan 24, 2025
abb02a2
remove redundant set(CMAKE_AUTOMOC TRUE)
herve-er Jan 24, 2025
599f812
Revert unwanted change on project config.
herve-er Jan 24, 2025
298ae0a
Merge branch 'KDESKTOP-1359-Vfs-functions-should-return-an-ExitInfo' …
herve-er Jan 24, 2025
6ae075f
Add a missing include.
herve-er Jan 24, 2025
7e3d9f3
Fix MockVfs in TestExecutorWorker
herve-er Jan 27, 2025
acd02e5
Merge branch 'develop' into KDESKTOP-1359-Vfs-functions-should-return…
herve-er Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extensions/windows/cfapi/Vfs/Vfs.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<Command>copy /Y "$(ProjectDir)..\Common\debug.h" "F:\Projects\desktop-kDrive\src\server\vfs\win\."
copy /Y "$(ProjectDir)$(TargetName).h" "F:\Projects\desktop-kDrive\src\server\vfs\win\."
copy /Y "$(TargetDir)$(TargetName).dll" "F:\Projects\build-desktop-kDrive-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug\bin\."
copy /Y "$(TargetDir)$(TargetName).pdb" "F:\Projects\build-desktop-kDrive-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug\bin\."
copy /Y "$(TargetDir)$(TargetName).pdb" "F:\Projects\build-desktop-kDrive-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug\."
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
Expand Down
2 changes: 1 addition & 1 deletion infomaniak-build-tools/windows/build-drive.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ $dependencies = @(
"${env:ProgramFiles(x86)}/Sentry-Native/bin/sentry",
"${env:ProgramFiles(x86)}/xxHash/bin/xxhash",
"$vfsDir/Vfs",
"$buildPath/bin/kDrivesyncengine_vfs_win"
"$buildPath/bin/kDrivecommonserver_vfs_win"
)

Write-Host "Copying dependencies to the folder $archivePath"
Expand Down
2 changes: 1 addition & 1 deletion infomaniak-build-tools/windows/upload-ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $files = @(
$app,
"kDrive.pdb",
"kDrive_client.pdb",
"kDrivesyncengine_vfs_win.pdb"
"kDrivecommonserver_vfs_win.pdb"
)

$headers = @{
Expand Down
86 changes: 86 additions & 0 deletions src/libcommon/utility/sourcelocation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Infomaniak kDrive - Desktop
* Copyright (C) 2023-2024 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#if defined(_WIN32)
// || defined(__APPLE__) still buggy on macOS
// https://www.reddit.com/r/cpp/comments/1b1pjii/comment/ksg8efc/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

#define SRC_LOC_AVALAIBALE
#endif

#ifdef SRC_LOC_AVALAIBALE
#include <source_location>
#endif // SRC_LOC_AVALAIBALE

#include <filesystem>
#include <string>

namespace KDC {

class SourceLocation {
public:
constexpr SourceLocation() = default;
#ifdef SRC_LOC_AVALAIBALE
[[nodiscard]] static consteval SourceLocation currentLoc(
const std::source_location& loc = std::source_location::current()) {
SourceLocation result;
result._line = loc.line();
result._fileName = loc.file_name();
result._functionName = loc.function_name();
return result;
}
#else
// This is a workaround for the lack of support for std::source_location.
// It is not as accurate as std::source_location but it is better than nothing.
// void foo(SourceLocation loc = currentLoc()) -> loc will be evaluated at the definition site instead of the call site.
#define currentLoc() currentLocCompatibility(__LINE__, __FILE__)
[[nodiscard]] static consteval SourceLocation currentLocCompatibility(uint32_t line, const char* file) {
SourceLocation result;
result._line = line;
result._fileName = file;
return result;
}
#endif // SRC_LOC_AVALAIBALE

[[nodiscard]] uint32_t line() const { return _line; }
[[nodiscard]] std::string fileName() const { return std::filesystem::path(_fileName).filename().string(); }
[[nodiscard]] std::string functionName() const {
std::string str(_functionName);
auto firstParenthesis = str.find_first_of('(');
str = firstParenthesis != std::string::npos
? str.substr(0, firstParenthesis)
: str; // "namespace::class::function(namespace::args)" -> "namespace::class::function"
auto lastColon = str.find_last_of(':');
return lastColon != std::string::npos ? str.substr(lastColon + 1) : str; // "namespace::class::function" -> "function"
}
[[nodiscard]] std::string toString() const {
return fileName() + ":" + std::to_string(line()) +
(functionName().empty() ? "" : "[" + functionName() + "]");
}


private:
uint32_t _line = 0;
const char* _fileName = "";
const char* _functionName = "";
};

} // namespace KDC
// namespace KDC
28 changes: 23 additions & 5 deletions src/libcommon/utility/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include <string>
Expand All @@ -28,6 +27,7 @@
#include <variant>
#include <qdebug.h>
#include <signal.h>
#include "sourcelocation.h"

namespace KDC {

Expand Down Expand Up @@ -230,32 +230,50 @@ enum class ExitCause {
MoveToTrashFailed,
InvalidName,
LiteSyncNotAllowed,
NotPlaceHolder,
NetworkTimeout,
SocketsDefuncted, // macOS: sockets defuncted by kernel
NotFound,
QuotaExceeded,
FullListParsingError,
OperationCanceled,
ShareLinkAlreadyExists
ShareLinkAlreadyExists,
InvalidArgument
};
std::string toString(ExitCause e);

struct ExitInfo {
ExitInfo() = default;
constexpr ExitInfo(const ExitCode &code, const ExitCause &cause) : _code(code), _cause(cause) {}
ExitInfo(const ExitCode &code) : _code(code) {}
constexpr ExitInfo(const ExitCode &code, const ExitCause &cause,
const SourceLocation srcLoc = SourceLocation::currentLoc()) :
_code(code),
_cause(cause), _srcLoc(srcLoc) {}

ExitInfo(const ExitCode &code, const SourceLocation srcLoc = SourceLocation::currentLoc()) :
_code(code), _srcLoc(srcLoc) {}

const ExitCode &code() const { return _code; }
const ExitCause &cause() const { return _cause; }
operator ExitCode() const { return _code; }
operator ExitCause() const { return _cause; }
explicit operator std::string() const { return "ExitInfo{" + toString(code()) + ", " + toString(cause()) + "}"; }
explicit operator std::string() const {
// Example: "ExitInfo{SystemError-NotFound from (file.cpp:42[functionName])}"
// Example: "ExitInfo{Ok-Unknown}"
return "ExitInfo{" + toString(code()) + "-" + toString(cause()) + srcLocStr() + "}";
}
constexpr operator bool() const { return _code == ExitCode::Ok; }
constexpr explicit operator int() const { return toInt(_code) * 100 + toInt(_cause); }
constexpr bool operator==(const ExitInfo &other) const { return _code == other._code && _cause == other._cause; }

private:
ExitCode _code{ExitCode::Unknown};
ExitCause _cause{ExitCause::Unknown};
SourceLocation _srcLoc;

std::string srcLocStr() const {
if (_code == ExitCode::Ok) return "";
return " from (" + _srcLoc.toString() + ")";
}
};
std::string toString(ExitInfo e);

Expand Down
8 changes: 8 additions & 0 deletions src/libcommonserver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
project(libcommonserver)

find_package(Qt6 REQUIRED Core)
find_package(SQLite3 3.8.0 REQUIRED)
find_package(Poco 1.13.3 REQUIRED Foundation Net JSON Util)
find_package(OpenSSL 3.1.0 REQUIRED SSL Crypto)
Expand All @@ -11,9 +12,13 @@ if (UNIX AND CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
endif ()
find_package(libzip 1.10.1 REQUIRED)

set(CMAKE_AUTOMOC TRUE)

add_definitions(-DUNICODE)
add_definitions(-D_UNICODE)

add_subdirectory(vfs)

# Sources
set(libcommonserver_SRCS
# Utility
Expand All @@ -34,6 +39,9 @@ set(libcommonserver_SRCS
# Io
io/filestat.h
io/iohelper.h io/iohelper.cpp
vfs/vfs.h vfs/vfs.cpp
vfs/workerinfo.h vfs/vfsworker.h
vfs/plugin.h vfs/plugin.cpp
)

if(APPLE)
Expand Down
Loading
Loading