diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index b76cb39b45..c914e5beb3 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -478,10 +478,6 @@ CF_SET_PIN_FLAGS pinRecurseModeToCfSetPinFlags(OCC::CfApiWrapper::SetPinRecurseM } } -OCC::CfApiWrapper::ConnectionKey::ConnectionKey() - : _data(new CF_CONNECTION_KEY, [](void *p) { delete reinterpret_cast(p); }) -{ -} OCC::CfApiWrapper::FileHandle::FileHandle() : _data(nullptr, [](void *) {}) @@ -722,15 +718,12 @@ OCC::Result OCC::CfApiWrapper::unregisterSyncRoot(const QString & } } -OCC::Result OCC::CfApiWrapper::connectSyncRoot(const QString &path, OCC::VfsCfApi *context) +OCC::Result OCC::CfApiWrapper::connectSyncRoot(const QString &path, OCC::VfsCfApi *context) { - auto key = ConnectionKey(); + CF_CONNECTION_KEY key; const auto p = path.toStdWString(); - const qint64 result = CfConnectSyncRoot(p.data(), - cfApiCallbacks, - context, - CF_CONNECT_FLAG_REQUIRE_PROCESS_INFO | CF_CONNECT_FLAG_REQUIRE_FULL_FILE_PATH | CF_CONNECT_FLAG_BLOCK_SELF_IMPLICIT_HYDRATION, - static_cast(key.get())); + const qint64 result = + CfConnectSyncRoot(p.data(), cfApiCallbacks, context, CF_CONNECT_FLAG_REQUIRE_PROCESS_INFO | CF_CONNECT_FLAG_REQUIRE_FULL_FILE_PATH | CF_CONNECT_FLAG_BLOCK_SELF_IMPLICIT_HYDRATION, &key); Q_ASSERT(result == S_OK); if (result != S_OK) { return QString::fromWCharArray(_com_error(result).ErrorMessage()); @@ -739,12 +732,13 @@ OCC::Result OCC::CfApiWrapper::connec } } -OCC::Result OCC::CfApiWrapper::disconnectSyncRoot(ConnectionKey &&key) +OCC::Result OCC::CfApiWrapper::disconnectSyncRoot(CF_CONNECTION_KEY &&key) { - const qint64 result = CfDisconnectSyncRoot(*static_cast(key.get())); - Q_ASSERT(result == S_OK); + const qint64 result = CfDisconnectSyncRoot(key); if (result != S_OK) { - return QString::fromWCharArray(_com_error(result).ErrorMessage()); + qCWarning(lcCfApiWrapper) << "Disconnecting sync root failed" << OCC::Utility::formatWinError(result); + Q_ASSERT(result == S_OK); + return OCC::Utility::formatWinError(result); } else { return {}; } diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.h b/src/libsync/vfs/cfapi/cfapiwrapper.h index 9db1083da6..329a8ca6fa 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.h +++ b/src/libsync/vfs/cfapi/cfapiwrapper.h @@ -72,8 +72,8 @@ NEXTCLOUD_CFAPI_EXPORT Result registerSyncRoot(const QString &pat NEXTCLOUD_CFAPI_EXPORT void unregisterSyncRootShellExtensions(const QString &providerName, const QString &folderAlias, const QString &accountDisplayName); NEXTCLOUD_CFAPI_EXPORT Result unregisterSyncRoot(const QString &path, const QString &providerName, const QString &accountDisplayName); -NEXTCLOUD_CFAPI_EXPORT Result connectSyncRoot(const QString &path, VfsCfApi *context); -NEXTCLOUD_CFAPI_EXPORT Result disconnectSyncRoot(ConnectionKey &&key); +Result connectSyncRoot(const QString &path, VfsCfApi *context); +Result disconnectSyncRoot(CF_CONNECTION_KEY &&key); NEXTCLOUD_CFAPI_EXPORT bool isAnySyncRoot(const QString &providerName, const QString &accountDisplayName); NEXTCLOUD_CFAPI_EXPORT bool isSparseFile(const QString &path); diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.cpp b/src/libsync/vfs/cfapi/vfs_cfapi.cpp index d292f23fc7..f5ee43c5e3 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.cpp +++ b/src/libsync/vfs/cfapi/vfs_cfapi.cpp @@ -103,7 +103,7 @@ class VfsCfApiPrivate { public: QList hydrationJobs; - cfapi::ConnectionKey connectionKey; + CF_CONNECTION_KEY connectionKey = {}; }; VfsCfApi::VfsCfApi(QObject *parent) @@ -146,9 +146,11 @@ void VfsCfApi::startImpl(const VfsSetupParams ¶ms) void VfsCfApi::stop() { - const auto result = cfapi::disconnectSyncRoot(std::move(d->connectionKey)); - if (!result) { - qCCritical(lcCfApi) << "Disconnect failed for" << QDir::toNativeSeparators(params().filesystemPath) << ":" << result.error(); + if (d->connectionKey.Internal != 0) { + const auto result = cfapi::disconnectSyncRoot(std::move(d->connectionKey)); + if (!result) { + qCCritical(lcCfApi) << "Disconnect failed for" << QDir::toNativeSeparators(params().filesystemPath) << ":" << result.error(); + } } }