From 8a181adb3a53d109f9f4e115086cc669bda53a18 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Mon, 29 Jun 2020 18:16:59 +0200 Subject: [PATCH] Always use an absolute remote path for GetFolderEncryptStatusJob It turns out this job expected an absolute remote path even in the case of a subfolder sync point. Signed-off-by: Kevin Ottens --- src/libsync/propagatedownloadencrypted.cpp | 13 ++++++++++++- src/libsync/propagateuploadencrypted.cpp | 19 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/libsync/propagatedownloadencrypted.cpp b/src/libsync/propagatedownloadencrypted.cpp index 4b989f59e..3b284e9f7 100644 --- a/src/libsync/propagatedownloadencrypted.cpp +++ b/src/libsync/propagatedownloadencrypted.cpp @@ -21,7 +21,18 @@ void PropagateDownloadEncrypted::start() { void PropagateDownloadEncrypted::checkFolderEncryptedStatus() { - auto getEncryptedStatus = new GetFolderEncryptStatusJob(_propagator->account(), _info.path()); + const auto rootPath = [=]() { + const auto result = _propagator->_remoteFolder; + if (result.startsWith('/')) { + return result.mid(1); + } else { + return result; + } + }(); + const auto remotePath = QString(rootPath + _item->_file); + const auto remoteParentPath = remotePath.left(remotePath.lastIndexOf('/')); + + auto getEncryptedStatus = new GetFolderEncryptStatusJob(_propagator->account(), remoteParentPath, this); connect(getEncryptedStatus, &GetFolderEncryptStatusJob::encryptStatusFolderReceived, this, &PropagateDownloadEncrypted::folderStatusReceived); diff --git a/src/libsync/propagateuploadencrypted.cpp b/src/libsync/propagateuploadencrypted.cpp index f8cce69ae..3bea68ffe 100644 --- a/src/libsync/propagateuploadencrypted.cpp +++ b/src/libsync/propagateuploadencrypted.cpp @@ -27,6 +27,23 @@ PropagateUploadEncrypted::PropagateUploadEncrypted(OwncloudPropagator *propagato void PropagateUploadEncrypted::start() { + const auto rootPath = [=]() { + const auto result = _propagator->_remoteFolder; + if (result.startsWith('/')) { + return result.mid(1); + } else { + return result; + } + }(); + const auto absoluteRemoteParentPath = [=]{ + auto path = QString(rootPath + _remoteParentPath); + if (path.endsWith('/')) { + path.chop(1); + } + return path; + }(); + + /* If the file is in a encrypted-enabled nextcloud instance, we need to * do the long road: Fetch the folder status of the encrypted bit, * if it's encrypted, find the ID of the folder. @@ -40,7 +57,7 @@ void PropagateUploadEncrypted::start() * If the folder is unencrypted we just follow the old way. */ qCDebug(lcPropagateUploadEncrypted) << "Starting to send an encrypted file!"; - auto getEncryptedStatus = new GetFolderEncryptStatusJob(_propagator->account(), _remoteParentPath, this); + auto getEncryptedStatus = new GetFolderEncryptStatusJob(_propagator->account(), absoluteRemoteParentPath, this); connect(getEncryptedStatus, &GetFolderEncryptStatusJob::encryptStatusFolderReceived, this, &PropagateUploadEncrypted::slotFolderEncryptedStatusFetched); -- 2.30.2