Skip to content

Commit

Permalink
KDESKTOP-823 - Fix CI build
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementKunz committed May 13, 2024
1 parent e22b64c commit edaaaad
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 55 deletions.
55 changes: 27 additions & 28 deletions src/libsyncengine/jobs/network/networkjobsparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
#include "networkjobsparams.h"

#include <map>
#include <unordered_map>

namespace KDC {

using enum ActionCode;

struct StringHash {
using is_transparent = void; // Enables heterogeneous operations.

Expand All @@ -35,36 +34,36 @@ struct StringHash {

ActionCode getActionCode(const std::string &action) noexcept {
static const std::unordered_map<std::string, ActionCode, StringHash, std::equal_to<>> actionMap = {
{"file_create", actionCodeCreate},
{"file_rename", actionCodeRename},
{"file_update", actionCodeEdit},
{"file_access", actionCodeAccess},
{"file_trash", actionCodeTrash},
{"file_delete", actionCodeDelete},
{"file_move", actionCodeMoveIn},
{"file_move_out", actionCodeMoveOut},
{"file_restore", actionCodeRestore},
{"file_share_create", actionCodeRestoreFileShareCreate},
{"file_share_delete", actionCodeRestoreFileShareDelete},
{"share_link_create", actionCodeRestoreShareLinkCreate},
{"share_link_delete", actionCodeRestoreShareLinkDelete},
{"acl_insert", actionCodeAccessRightInsert},
{"acl_update", actionCodeAccessRightUpdate},
{"acl_remove", actionCodeAccessRightRemove},
{"acl_user_insert", actionCodeAccessRightUserInsert},
{"acl_user_update", actionCodeAccessRightUserUpdate},
{"acl_user_remove", actionCodeAccessRightUserRemove},
{"acl_team_insert", actionCodeAccessRightTeamInsert},
{"acl_team_update", actionCodeAccessRightTeamUpdate},
{"acl_team_remove", actionCodeAccessRightTeamRemove},
{"acl_main_users_insert", actionCodeAccessRightMainUsersInsert},
{"acl_main_users_update", actionCodeAccessRightMainUsersUpdate},
{"acl_main_users_remove", actionCodeAccessRightMainUsersRemove}
{"file_create", ActionCode::actionCodeCreate},
{"file_rename", ActionCode::actionCodeRename},
{"file_update", ActionCode::actionCodeEdit},
{"file_access", ActionCode::actionCodeAccess},
{"file_trash", ActionCode::actionCodeTrash},
{"file_delete", ActionCode::actionCodeDelete},
{"file_move", ActionCode::actionCodeMoveIn},
{"file_move_out", ActionCode::actionCodeMoveOut},
{"file_restore", ActionCode::actionCodeRestore},
{"file_share_create", ActionCode::actionCodeRestoreFileShareCreate},
{"file_share_delete", ActionCode::actionCodeRestoreFileShareDelete},
{"share_link_create", ActionCode::actionCodeRestoreShareLinkCreate},
{"share_link_delete", ActionCode::actionCodeRestoreShareLinkDelete},
{"acl_insert", ActionCode::actionCodeAccessRightInsert},
{"acl_update", ActionCode::actionCodeAccessRightUpdate},
{"acl_remove", ActionCode::actionCodeAccessRightRemove},
{"acl_user_insert", ActionCode::actionCodeAccessRightUserInsert},
{"acl_user_update", ActionCode::actionCodeAccessRightUserUpdate},
{"acl_user_remove", ActionCode::actionCodeAccessRightUserRemove},
{"acl_team_insert", ActionCode::actionCodeAccessRightTeamInsert},
{"acl_team_update", ActionCode::actionCodeAccessRightTeamUpdate},
{"acl_team_remove", ActionCode::actionCodeAccessRightTeamRemove},
{"acl_main_users_insert", ActionCode::actionCodeAccessRightMainUsersInsert},
{"acl_main_users_update", ActionCode::actionCodeAccessRightMainUsersUpdate},
{"acl_main_users_remove", ActionCode::actionCodeAccessRightMainUsersRemove}
};

if (const auto it = actionMap.find(action); it != actionMap.cend()) return it->second;

return actionCodeUnknown;
return ActionCode::actionCodeUnknown;
};

NetworkErrorCode getNetworkErrorCode(const std::string &errorCode) noexcept {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@

namespace KDC {

using enum ActionCode;

RemoteFileSystemObserverWorker::RemoteFileSystemObserverWorker(std::shared_ptr<SyncPal> syncPal, const std::string &name,
const std::string &shortName)
: FileSystemObserverWorker(syncPal, name, shortName, ReplicaSideRemote), _driveDbId(syncPal->_driveDbId) {}
Expand Down Expand Up @@ -598,14 +596,14 @@ ExitCode RemoteFileSystemObserverWorker::processAction(const SyncName &usedName,
// Process action
switch (actionInfo.actionCode) {
// Item added
case actionCodeAccessRightInsert:
case actionCodeAccessRightUpdate:
case actionCodeAccessRightUserInsert:
case actionCodeAccessRightUserUpdate:
case actionCodeAccessRightTeamInsert:
case actionCodeAccessRightTeamUpdate:
case actionCodeAccessRightMainUsersInsert:
case actionCodeAccessRightMainUsersUpdate: {
case ActionCode::actionCodeAccessRightInsert:
case ActionCode::actionCodeAccessRightUpdate:
case ActionCode::actionCodeAccessRightUserInsert:
case ActionCode::actionCodeAccessRightUserUpdate:
case ActionCode::actionCodeAccessRightTeamInsert:
case ActionCode::actionCodeAccessRightTeamUpdate:
case ActionCode::actionCodeAccessRightMainUsersInsert:
case ActionCode::actionCodeAccessRightMainUsersUpdate: {
bool hasRights = false;
SyncTime createdAt = 0;
SyncTime modtime = 0;
Expand All @@ -624,9 +622,9 @@ ExitCode RemoteFileSystemObserverWorker::processAction(const SyncName &usedName,
item.setSize(size);
[[fallthrough]];
}
case actionCodeMoveIn:
case actionCodeRestore:
case actionCodeCreate:
case ActionCode::actionCodeMoveIn:
case ActionCode::actionCodeRestore:
case ActionCode::actionCodeCreate:
_snapshot->updateItem(item);

if (actionInfo.type == NodeTypeDirectory && actionInfo.actionCode != ActionCode::actionCodeCreate) {
Expand All @@ -647,21 +645,21 @@ ExitCode RemoteFileSystemObserverWorker::processAction(const SyncName &usedName,
break;

// Item renamed
case actionCodeRename:
case ActionCode::actionCodeRename:
_syncPal->removeItemFromTmpBlacklist(actionInfo.nodeId, ReplicaSideRemote);
_snapshot->updateItem(item);
break;

// Item edited
case actionCodeEdit:
case ActionCode::actionCodeEdit:
_snapshot->updateItem(item);
break;

// Item removed
case actionCodeAccessRightRemove:
case actionCodeAccessRightUserRemove:
case actionCodeAccessRightTeamRemove:
case actionCodeAccessRightMainUsersRemove: {
case ActionCode::actionCodeAccessRightRemove:
case ActionCode::actionCodeAccessRightUserRemove:
case ActionCode::actionCodeAccessRightTeamRemove:
case ActionCode::actionCodeAccessRightMainUsersRemove: {
bool hasRights = false;
SyncTime createdAt = 0;
SyncTime modtime = 0;
Expand All @@ -676,11 +674,11 @@ ExitCode RemoteFileSystemObserverWorker::processAction(const SyncName &usedName,
if (hasRights) break; // Current user still have the right to access this item, ignore action.
[[fallthrough]];
}
case actionCodeMoveOut:
case ActionCode::actionCodeMoveOut:
// Ignore move out action if destination is inside the synced folder.
if (movedItems.find(actionInfo.nodeId) != movedItems.end()) break;
[[fallthrough]];
case actionCodeTrash:
case ActionCode::actionCodeTrash:
_syncPal->removeItemFromTmpBlacklist(actionInfo.nodeId, ReplicaSideRemote);
if (!_snapshot->removeItem(actionInfo.nodeId)) {
LOGW_SYNCPAL_WARN(_logger, L"Fail to remove item: " << SyncName2WStr(actionInfo.name).c_str() << L" ("
Expand All @@ -691,12 +689,12 @@ ExitCode RemoteFileSystemObserverWorker::processAction(const SyncName &usedName,
break;

// Ignored actions
case actionCodeAccess:
case actionCodeDelete:
case actionCodeRestoreFileShareCreate:
case actionCodeRestoreFileShareDelete:
case actionCodeRestoreShareLinkCreate:
case actionCodeRestoreShareLinkDelete:
case ActionCode::actionCodeAccess:
case ActionCode::actionCodeDelete:
case ActionCode::actionCodeRestoreFileShareCreate:
case ActionCode::actionCodeRestoreFileShareDelete:
case ActionCode::actionCodeRestoreShareLinkCreate:
case ActionCode::actionCodeRestoreShareLinkDelete:
// Ignore these actions
break;

Expand Down

0 comments on commit edaaaad

Please sign in to comment.