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

[stable-3.12] Bugfix/update encryption state when server change #6843

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 9 additions & 8 deletions src/gui/folderstatusmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ Qt::ItemFlags FolderStatusModel::flags(const QModelIndex &index) const
return Qt::ItemIsEnabled;
case SubFolder:
if (supportsSelectiveSync) {
if (info && info->_isEncrypted && !_accountState->account()->capabilities().clientSideEncryptionAvailable()) {
return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
}
return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
} else {
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
Expand Down Expand Up @@ -613,14 +616,12 @@ void FolderStatusModel::fetchMore(const QModelIndex &parent)

const auto job = new LsColJob(_accountState->account(), path);
info->_fetchingJob = job;
auto props = QList<QByteArray>() << "resourcetype"
<< "http://owncloud.org/ns:size"
<< "http://owncloud.org/ns:permissions"
<< "http://nextcloud.org/ns:is-mount-root"
<< "http://owncloud.org/ns:fileid";
if (_accountState->account()->capabilities().clientSideEncryptionAvailable()) {
props << "http://nextcloud.org/ns:is-encrypted";
}
const auto props = QList<QByteArray>() << "resourcetype"
<< "http://owncloud.org/ns:size"
<< "http://owncloud.org/ns:permissions"
<< "http://nextcloud.org/ns:is-mount-root"
<< "http://owncloud.org/ns:fileid"
<< "http://nextcloud.org/ns:is-encrypted";
job->setProperties(props);

job->setTimeout(60 * 1000);
Expand Down
6 changes: 2 additions & 4 deletions src/gui/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,8 @@ void FolderWizardRemotePath::slotTypedPathFound(const QStringList &subpaths)
LsColJob *FolderWizardRemotePath::runLsColJob(const QString &path)
{
auto *job = new LsColJob(_account, path);
auto props = QList<QByteArray>() << "resourcetype";
if (_account->capabilities().clientSideEncryptionAvailable()) {
props << "http://nextcloud.org/ns:is-encrypted";
}
const auto props = QList<QByteArray>() << "resourcetype"
<< "http://nextcloud.org/ns:is-encrypted";
job->setProperties(props);
connect(job, &LsColJob::directoryListingSubfolders,
this, &FolderWizardRemotePath::slotUpdateDirectories);
Expand Down
6 changes: 2 additions & 4 deletions src/gui/selectivesyncdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ void SelectiveSyncWidget::refreshFolders()

auto *job = new LsColJob(_account, _folderPath);
auto props = QList<QByteArray>() << "resourcetype"
<< "http://owncloud.org/ns:size";
if (_account->capabilities().clientSideEncryptionAvailable()) {
props << "http://nextcloud.org/ns:is-encrypted";
}
<< "http://owncloud.org/ns:size"
<< "http://nextcloud.org/ns:is-encrypted";
job->setProperties(props);
connect(job, &LsColJob::directoryListingSubfolders,
this, &SelectiveSyncWidget::slotUpdateDirectories);
Expand Down
7 changes: 7 additions & 0 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,13 @@ void ProcessDirectoryJob::processFileFinalize(
const SyncFileItemPtr &item, PathTuple path, bool recurse,
QueryMode recurseQueryLocal, QueryMode recurseQueryServer)
{
if (item->isEncrypted() && !_discoveryData->_account->capabilities().clientSideEncryptionAvailable()) {
item->_instruction = CSyncEnums::CSYNC_INSTRUCTION_IGNORE;
item->_direction = SyncFileItem::None;
emit _discoveryData->itemDiscovered(item);
return;
}

// Adjust target path for virtual-suffix files
if (isVfsWithSuffix()) {
if (item->_type == ItemTypeVirtualFile) {
Expand Down
11 changes: 6 additions & 5 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,15 @@
<< "http://owncloud.org/ns:downloadURL"
<< "http://owncloud.org/ns:dDC"
<< "http://owncloud.org/ns:permissions"
<< "http://owncloud.org/ns:checksums";
<< "http://owncloud.org/ns:checksums"
<< "http://nextcloud.org/ns:is-encrypted";

if (_isRootPath)
props << "http://owncloud.org/ns:data-fingerprint";
if (_account->serverVersionInt() >= Account::makeServerVersion(10, 0, 0)) {
// Server older than 10.0 have performances issue if we ask for the share-types on every PROPFIND
props << "http://owncloud.org/ns:share-types";
}
if (_account->capabilities().clientSideEncryptionAvailable()) {
props << "http://nextcloud.org/ns:is-encrypted";
}
if (_account->capabilities().filesLockAvailable()) {
props << "http://nextcloud.org/ns:lock"
<< "http://nextcloud.org/ns:lock-owner-displayname"
Expand Down Expand Up @@ -623,10 +621,13 @@
emit finished(HttpError{ 0, _error });
deleteLater();
return;
} else if (isE2eEncrypted()) {
} else if (isE2eEncrypted() && _account->capabilities().clientSideEncryptionAvailable()) {
emit etag(_firstEtag, QDateTime::fromString(QString::fromUtf8(_lsColJob->responseTimestamp()), Qt::RFC2822Date));
fetchE2eMetadata();
return;
} else if (isE2eEncrypted() && !_account->capabilities().clientSideEncryptionAvailable()) {
emit etag(_firstEtag, QDateTime::fromString(QString::fromUtf8(_lsColJob->responseTimestamp()), Qt::RFC2822Date));

Check warning on line 629 in src/libsync/discoveryphase.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/discoveryphase.cpp:629:14 [cppcoreguidelines-init-variables]

variable 'etag' is not initialized
emit finished(_results);

Check warning on line 630 in src/libsync/discoveryphase.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/discoveryphase.cpp:630:14 [cppcoreguidelines-init-variables]

variable 'finished' is not initialized
}
emit etag(_firstEtag, QDateTime::fromString(QString::fromUtf8(_lsColJob->responseTimestamp()), Qt::RFC2822Date));
emit finished(_results);
Expand Down
7 changes: 1 addition & 6 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/owncloudpropagator.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/owncloudpropagator.cpp

File src/libsync/owncloudpropagator.cpp does not conform to Custom style guidelines. (lines 1099)
* Copyright (C) by Olivier Goffart <[email protected]>
* Copyright (C) by Klaas Freitag <[email protected]>
*
Expand Down Expand Up @@ -315,10 +315,6 @@

bool PropagateItemJob::hasEncryptedAncestor() const
{
if (!propagator()->account()->capabilities().clientSideEncryptionAvailable()) {
return false;
}

SyncJournalFileRecord rec;
return propagator()->_journal->findEncryptedAncestorForRecord(_item->_file, &rec)
&& rec.isValid() && rec.isE2eEncrypted();
Expand Down Expand Up @@ -1100,8 +1096,7 @@

const auto accountPtr = account();

if (!accountPtr->capabilities().clientSideEncryptionAvailable() ||
!parentRec.isValid() ||
if (!parentRec.isValid() ||
!parentRec.isE2eEncrypted()) {
return false;
}
Expand Down
Loading