Merge pull request #3183 from nextcloud/bugfix/warn-if-e2ee-with-vfs

Warn user if using e2ee and vfs together
This commit is contained in:
Matthieu Gallien 2021-05-18 14:08:53 +02:00 committed by GitHub
commit 79e6459bd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 2 deletions

View file

@ -55,8 +55,6 @@
#include <QVariant> #include <QVariant>
#include <QJsonDocument> #include <QJsonDocument>
#include <QToolTip> #include <QToolTip>
#include <qstringlistmodel.h>
#include <qpropertyanimation.h>
#include "account.h" #include "account.h"
@ -66,6 +64,8 @@ constexpr auto propertyFolderInfo = "folderInfo";
namespace OCC { namespace OCC {
class AccountSettings;
Q_LOGGING_CATEGORY(lcAccountSettings, "nextcloud.gui.account.settings", QtInfoMsg) Q_LOGGING_CATEGORY(lcAccountSettings, "nextcloud.gui.account.settings", QtInfoMsg)
static const char progressBarStyleC[] = static const char progressBarStyleC[] =
@ -78,6 +78,24 @@ static const char progressBarStyleC[] =
"background-color: %1; width: 1px;" "background-color: %1; width: 1px;"
"}"; "}";
bool showEnableE2eeWithVirtualFilesWarningDialog()
{
QMessageBox e2eeWithVirtualFilesWarningMsgBox;
e2eeWithVirtualFilesWarningMsgBox.setText(AccountSettings::tr("End-to-End Encryption with Virtual Files"));
e2eeWithVirtualFilesWarningMsgBox.setInformativeText(AccountSettings::tr("You seem to have the Virtual Files feature enabled on this folder. At "
" the moment, it is not possible to implicitly download virtual files that are "
"End-to-End encrypted. To get the best experience with Virtual Files and"
" End-to-End Encryption, make sure the encrypted folder is marked with"
" \"Make always available locally\"."));
e2eeWithVirtualFilesWarningMsgBox.setIcon(QMessageBox::Warning);
const auto dontEncryptButton = e2eeWithVirtualFilesWarningMsgBox.button(QMessageBox::StandardButton::Ok);
const auto encryptButton = e2eeWithVirtualFilesWarningMsgBox.button(QMessageBox::StandardButton::Cancel);
dontEncryptButton->setText(AccountSettings::tr("Don't encrypt folder"));
encryptButton->setText(AccountSettings::tr("Encrypt folder"));
return e2eeWithVirtualFilesWarningMsgBox.clickedButton() != dontEncryptButton;
}
/** /**
* Adjusts the mouse cursor based on the region it is on over the folder tree view. * Adjusts the mouse cursor based on the region it is on over the folder tree view.
* *
@ -315,6 +333,14 @@ void AccountSettings::slotMarkSubfolderEncrypted(FolderStatusModel::SubFolderInf
return; return;
} }
const auto folder = folderInfo->_folder;
Q_ASSERT(folder);
if (folder->virtualFilesEnabled()
&& folder->vfs().mode() == Vfs::WindowsCfApi
&& !showEnableE2eeWithVirtualFilesWarningDialog()) {
return;
}
// Folder info have directory paths in Foo/Bar/ convention... // Folder info have directory paths in Foo/Bar/ convention...
Q_ASSERT(!folderInfo->_path.startsWith('/') && folderInfo->_path.endsWith('/')); Q_ASSERT(!folderInfo->_path.startsWith('/') && folderInfo->_path.endsWith('/'));
// But EncryptFolderJob expects directory path Foo/Bar convention // But EncryptFolderJob expects directory path Foo/Bar convention

View file

@ -16,6 +16,7 @@
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QMessageBox>
#include "cfapiwrapper.h" #include "cfapiwrapper.h"
#include "hydrationjob.h" #include "hydrationjob.h"
@ -308,6 +309,17 @@ void VfsCfApi::requestHydration(const QString &requestId, const QString &path)
// of the placeholder with decrypted data // of the placeholder with decrypted data
if (record._isE2eEncrypted || !record._e2eMangledName.isEmpty()) { if (record._isE2eEncrypted || !record._e2eMangledName.isEmpty()) {
qCInfo(lcCfApi) << "Couldn't hydrate, the file is E2EE this is not supported"; qCInfo(lcCfApi) << "Couldn't hydrate, the file is E2EE this is not supported";
QMessageBox e2eeFileDownloadRequestWarningMsgBox;
e2eeFileDownloadRequestWarningMsgBox.setText(tr("Download of End-to-End encrypted file failed"));
e2eeFileDownloadRequestWarningMsgBox.setInformativeText(tr("It seems that you are trying to download a virtual file that"
" is End-to-End encrypted. Implicitly downloading such files is not"
" supported at the moment. To workaround this issue, go to the"
" settings and mark the encrypted folder with \"Make always available"
" locally\"."));
e2eeFileDownloadRequestWarningMsgBox.setIcon(QMessageBox::Warning);
e2eeFileDownloadRequestWarningMsgBox.exec();
emit hydrationRequestFailed(requestId); emit hydrationRequestFailed(requestId);
return; return;
} }