]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
use a getter to query encryption status
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 29 Mar 2023 07:22:22 +0000 (09:22 +0200)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 31 Mar 2023 15:18:28 +0000 (17:18 +0200)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
23 files changed:
src/common/syncjournaldb.cpp
src/common/syncjournalfilerecord.h
src/gui/accountsettings.cpp
src/gui/filedetails/sharemodel.cpp
src/gui/folder.cpp
src/gui/folderstatusmodel.cpp
src/gui/folderstatusmodel.h
src/gui/socketapi/socketapi.cpp
src/gui/tray/activitylistmodel.cpp
src/libsync/discovery.cpp
src/libsync/discoveryphase.cpp
src/libsync/discoveryphase.h
src/libsync/owncloudpropagator.cpp
src/libsync/owncloudpropagator.h
src/libsync/propagatedownload.cpp
src/libsync/propagatedownload.h
src/libsync/propagateremotedelete.cpp
src/libsync/propagateremotedeleteencryptedrootfolder.cpp
src/libsync/propagateremotemkdir.cpp
src/libsync/propagateupload.cpp
src/libsync/syncfileitem.cpp
src/libsync/syncfileitem.h
test/testfolderman.cpp

index fc3c4149fd5c2adf181a45dc3a3233ed2fbb36ff..2a91a8f79b3f70c26dee94aeb86fbeb83fb35439 100644 (file)
@@ -910,7 +910,7 @@ Result<void, QString> SyncJournalDb::setFileRecord(const SyncJournalFileRecord &
                  << "modtime:" << record._modtime << "type:" << record._type << "etag:" << record._etag
                  << "fileId:" << record._fileId << "remotePerm:" << record._remotePerm.toString()
                  << "fileSize:" << record._fileSize << "checksum:" << record._checksumHeader
-                 << "e2eMangledName:" << record.e2eMangledName() << "isE2eEncrypted:" << record._isE2eEncrypted
+                 << "e2eMangledName:" << record.e2eMangledName() << "isE2eEncrypted:" << record.isE2eEncrypted()
                  << "lock:" << (record._lockstate._locked ? "true" : "false")
                  << "lock owner type:" << record._lockstate._lockOwnerType
                  << "lock owner:" << record._lockstate._lockOwnerDisplayName
@@ -968,7 +968,7 @@ Result<void, QString> SyncJournalDb::setFileRecord(const SyncJournalFileRecord &
     query->bindValue(15, checksum);
     query->bindValue(16, contentChecksumTypeId);
     query->bindValue(17, record._e2eMangledName);
-    query->bindValue(18, record._isE2eEncrypted);
+    query->bindValue(18, record.isE2eEncrypted());
     query->bindValue(19, record._lockstate._locked ? 1 : 0);
     query->bindValue(20, record._lockstate._lockOwnerType);
     query->bindValue(21, record._lockstate._lockOwnerDisplayName);
index a846aeeb17bf18088bea77a99b80e1ad0e9fda8e..f32e4c588b381f360ddc4a3ab2a22640b94fb053 100644 (file)
@@ -67,6 +67,7 @@ public:
     [[nodiscard]] bool isVirtualFile() const { return _type == ItemTypeVirtualFile || _type == ItemTypeVirtualFileDownload; }
     [[nodiscard]] QString path() const { return QString::fromUtf8(_path); }
     [[nodiscard]] QString e2eMangledName() const { return QString::fromUtf8(_e2eMangledName); }
+    [[nodiscard]] bool isE2eEncrypted() const { return _isE2eEncrypted; }
 
     QByteArray _path;
     quint64 _inode = 0;
index 61b6fcb46a8a450c67c8e984a563dcb4230e564d..0212a2812588e9d1c6a51b0c3ca70ed159563ddb 100644 (file)
@@ -520,7 +520,7 @@ void AccountSettings::slotSubfolderContextMenuRequested(const QModelIndex& index
     if (acc->capabilities().clientSideEncryptionAvailable()) {
         // Verify if the folder is empty before attempting to encrypt.
 
-        const auto isEncrypted = info->_isEncrypted;
+        const auto isEncrypted = info->isEncrypted();
         const auto isParentEncrypted = _model->isAnyAncestorEncrypted(index);
 
         if (!isEncrypted && !isParentEncrypted) {
index f210e4550e78334c013effe3339ff338cb54372a..cee89c6d1b069a3e898e19fe9e2aef64ead11555 100644 (file)
@@ -250,9 +250,9 @@ void ShareModel::updateData()
 
     _numericFileId = fileRecord.numericFileId();
 
-    _isEncryptedItem = fileRecord._isE2eEncrypted;
+    _isEncryptedItem = fileRecord.isE2eEncrypted();
     _isSecureFileDropSupportedFolder =
-        fileRecord._isE2eEncrypted && fileRecord.e2eMangledName().isEmpty() && _accountState->account()->secureFileDropSupported();
+        fileRecord.isE2eEncrypted() && fileRecord.e2eMangledName().isEmpty() && _accountState->account()->secureFileDropSupported();
 
     // Will get added when shares are fetched if no link shares are fetched
     _placeholderLinkShare.reset(new Share(_accountState->account(),
index 38db18d5547e659756329a074f4a355a0e94ee89..eb7d6c01042610d7a6aa533c58fd2696c3396878 100644 (file)
@@ -1347,7 +1347,7 @@ void Folder::removeLocalE2eFiles()
     QStringList e2eFoldersToBlacklist;
     const auto couldGetFiles = _journal.getFilesBelowPath("", [this, &e2eFoldersToBlacklist, &folderRootDir](const SyncJournalFileRecord &rec) {
         // We only want to add the root-most encrypted folder to the blacklist
-        if (rec.isValid() && rec._isE2eEncrypted && rec.isDirectory()) {
+        if (rec.isValid() && rec.isE2eEncrypted() && rec.isDirectory()) {
             QDir pathDir(_canonicalLocalPath + rec.path());
             bool parentPathEncrypted = false;
 
@@ -1359,7 +1359,7 @@ void Folder::removeLocalE2eFiles()
                     qCWarning(lcFolder) << "Failed to get file record for" << currentCanonicalPath;
                 }
 
-                if (dirRec._isE2eEncrypted) {
+                if (dirRec.isE2eEncrypted()) {
                     parentPathEncrypted = true;
                     break;
                 }
index 2855ef51d9ddac13d9da7c1afb4f6412cc872dc1..8a92b291ab678d99b1d10ab36b5bf8433cfd7dbe 100644 (file)
@@ -162,7 +162,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
         case Qt::DisplayRole: {
             //: Example text: "File.txt (23KB)"
             const auto &xParent = static_cast<SubFolderInfo *>(index.internalPointer());
-            const auto suffix = (subfolderInfo._isNonDecryptable && subfolderInfo._checked && (!xParent || !xParent->_isEncrypted))
+            const auto suffix = (subfolderInfo._isNonDecryptable && subfolderInfo._checked && (!xParent || !xParent->isEncrypted()))
                 ? QStringLiteral(" - ") + tr("Could not decrypt!")
                 : QString{};
             return subfolderInfo._size < 0 ? QString(subfolderInfo._name + suffix) : QString(tr("%1 (%2)").arg(subfolderInfo._name, Utility::octetsToString(subfolderInfo._size)) + suffix);
@@ -179,7 +179,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
             if (subfolderInfo._isNonDecryptable && subfolderInfo._checked) {
                 return QIcon(QLatin1String(":/client/theme/lock-broken.svg"));
             }
-            if (subfolderInfo._isEncrypted) {
+            if (subfolderInfo.isEncrypted()) {
                 return QIcon(QLatin1String(":/client/theme/lock-https.svg"));
             } else if (subfolderInfo._size > 0 && isAnyAncestorEncrypted(index)) {
                 return QIcon(QLatin1String(":/client/theme/lock-broken.svg"));
@@ -445,7 +445,7 @@ bool FolderStatusModel::isAnyAncestorEncrypted(const QModelIndex &index) const
     auto parentIndex = parent(index);
     while (parentIndex.isValid()) {
         const auto info = infoForIndex(parentIndex);
-        if (info->_isEncrypted) {
+        if (info->isEncrypted()) {
             return true;
         }
         parentIndex = parent(parentIndex);
@@ -607,7 +607,7 @@ void FolderStatusModel::fetchMore(const QModelIndex &parent)
     QString path = info->_folder->remotePathTrailingSlash();
 
     // info->_path always contains non-mangled name, so we need to use mangled when requesting nested folders for encrypted subfolders as required by LsColJob
-    const QString infoPath = (info->_isEncrypted && !info->_e2eMangledName.isEmpty()) ? info->_e2eMangledName : info->_path;
+    const QString infoPath = (info->isEncrypted() && !info->_e2eMangledName.isEmpty()) ? info->_e2eMangledName : info->_path;
 
     if (infoPath != QLatin1String("/")) {
         path += infoPath;
@@ -752,7 +752,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
         newInfo._isEncrypted = encryptionMap.value(removeTrailingSlash(path)).toString() == QStringLiteral("1");
         newInfo._path = relativePath;
 
-        newInfo._isNonDecryptable = newInfo._isEncrypted
+        newInfo._isNonDecryptable = newInfo.isEncrypted()
             && _accountState->account()->e2e() && !_accountState->account()->e2e()->_publicKey.isNull()
             && _accountState->account()->e2e()->_privateKey.isNull();
 
@@ -762,7 +762,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
         }
         if (rec.isValid()) {
             newInfo._name = removeTrailingSlash(rec._path).split('/').last();
-            if (rec._isE2eEncrypted && !rec._e2eMangledName.isEmpty()) {
+            if (rec.isE2eEncrypted() && !rec._e2eMangledName.isEmpty()) {
                 // we must use local path for Settings Dialog's filesystem tree, otherwise open and create new folder actions won't work
                 // hence, we are storing _e2eMangledName separately so it can be use later for LsColJob
                 newInfo._e2eMangledName = relativePath;
index e2397295c7d4a6077cf77570c6ee6ba1f47e65e7..96b7467d14ddc1110e88d79acfa666c80e1d96f9 100644 (file)
@@ -85,6 +85,8 @@ public:
         // Whether this has a FetchLabel subrow
         [[nodiscard]] bool hasLabel() const;
 
+        [[nodiscard]] bool isEncrypted() const { return _isEncrypted; }
+
         // Reset all subfolders and fetch status
         void resetSubs(FolderStatusModel *model, QModelIndex index);
 
index 4e0ef59ae1dff4a4324bec80fdb75acce048fa79..7b8772a7e403e4c776f470b3e7e67a5f4fb90c90 100644 (file)
@@ -1220,7 +1220,7 @@ void SocketApi::sendEncryptFolderCommandMenuEntries(const QFileInfo &fileInfo,
     bool anyAncestorEncrypted = false;
     auto ancestor = fileData.parentFolder();
     while (ancestor.journalRecord().isValid()) {
-        if (ancestor.journalRecord()._isE2eEncrypted) {
+        if (ancestor.journalRecord().isE2eEncrypted()) {
             anyAncestorEncrypted = true;
             break;
         }
@@ -1352,8 +1352,8 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
         FileData fileData = FileData::get(argument);
         const auto record = fileData.journalRecord();
         const bool isOnTheServer = record.isValid();
-        const auto isE2eEncryptedPath = fileData.journalRecord()._isE2eEncrypted || !fileData.journalRecord()._e2eMangledName.isEmpty();
-        const auto isE2eEncryptedRootFolder = fileData.journalRecord()._isE2eEncrypted && fileData.journalRecord()._e2eMangledName.isEmpty();
+        const auto isE2eEncryptedPath = fileData.journalRecord().isE2eEncrypted() || !fileData.journalRecord()._e2eMangledName.isEmpty();
+        const auto isE2eEncryptedRootFolder = fileData.journalRecord().isE2eEncrypted() && fileData.journalRecord()._e2eMangledName.isEmpty();
         auto flagString = isOnTheServer && !isE2eEncryptedPath ? QLatin1String("::") : QLatin1String(":d:");
 
         const QFileInfo fileInfo(fileData.localPath);
index 6b6b4569cc8b47063659f61111b4736bb251b25b..b820ed941c2b17e588dee343efcd7ef0b91caf24 100644 (file)
@@ -159,7 +159,7 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
                 if (!folder->journalDb()->getFileRecord(fileName.mid(1), &rec)) {
                     qCWarning(lcActivity) << "could not get file from local DB" << fileName.mid(1);
                 }
-                if (rec.isValid() && (rec._isE2eEncrypted || !rec._e2eMangledName.isEmpty())) {
+                if (rec.isValid() && (rec.isE2eEncrypted() || !rec._e2eMangledName.isEmpty())) {
                     return QString();
                 }
             }
index e2c8a91d52c90956decfedeae9ba19a55d1b0029..c9aa2d02a1aaac004aef2eeaf15eef53f05d6db8 100644 (file)
@@ -218,7 +218,7 @@ void ProcessDirectoryJob::process()
         if (handleExcluded(path._target, e, isHidden))
             continue;
 
-        const auto isEncryptedFolderButE2eIsNotSetup = e.serverEntry.isValid() && e.serverEntry.isE2eEncrypted &&
+        const auto isEncryptedFolderButE2eIsNotSetup = e.serverEntry.isValid() && e.serverEntry.isE2eEncrypted() &&
             _discoveryData->_account->e2e() && !_discoveryData->_account->e2e()->_publicKey.isNull() && _discoveryData->_account->e2e()->_privateKey.isNull();
 
         if (isEncryptedFolderButE2eIsNotSetup) {
@@ -431,7 +431,7 @@ void ProcessDirectoryJob::processFile(PathTuple path,
                               << " | fileid: " << dbEntry._fileId << "//" << serverEntry.fileId
                               << " | inode: " << dbEntry._inode << "/" << localEntry.inode << "/"
                               << " | type: " << dbEntry._type << "/" << localEntry.type << "/" << (serverEntry.isDirectory ? ItemTypeDirectory : ItemTypeFile)
-                              << " | e2ee: " << dbEntry._isE2eEncrypted << "/" << serverEntry.isE2eEncrypted
+                              << " | e2ee: " << dbEntry.isE2eEncrypted() << "/" << serverEntry.isE2eEncrypted()
                               << " | e2eeMangledName: " << dbEntry.e2eMangledName() << "/" << serverEntry.e2eMangledName
                               << " | file lock: " << localFileIsLocked << "//" << serverFileIsLocked;
 
@@ -532,7 +532,7 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(
     item->_etag = serverEntry.etag;
     item->_directDownloadUrl = serverEntry.directDownloadUrl;
     item->_directDownloadCookies = serverEntry.directDownloadCookies;
-    item->_isEncrypted = serverEntry.isE2eEncrypted;
+    item->_isEncrypted = serverEntry.isE2eEncrypted();
     item->_encryptedFileName = [=] {
         if (serverEntry.e2eMangledName.isEmpty()) {
             return QString();
@@ -656,7 +656,7 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(
             // or, maybe, add a flag to the database - vfsE2eeSizeCorrected? if it is not set - subtract it from the placeholder's size and re-create/update a placeholder?
             const QueryMode serverQueryMode = [this, &dbEntry, &serverEntry]() {
                 const bool isVfsModeOn = _discoveryData && _discoveryData->_syncOptions._vfs && _discoveryData->_syncOptions._vfs->mode() != Vfs::Off;
-                if (isVfsModeOn && dbEntry.isDirectory() && dbEntry._isE2eEncrypted) {
+                if (isVfsModeOn && dbEntry.isDirectory() && dbEntry.isE2eEncrypted()) {
                     qint64 localFolderSize = 0;
                     const auto listFilesCallback = [&localFolderSize](const OCC::SyncJournalFileRecord &record) {
                         if (record.isFile()) {
@@ -1240,7 +1240,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
             return false;
         }
 
-        if (base._isE2eEncrypted || isInsideEncryptedTree()) {
+        if (base.isE2eEncrypted() || isInsideEncryptedTree()) {
             return false;
         }
 
@@ -1289,7 +1289,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
 
     // If it's not a move it's just a local-NEW
     if (!moveCheck()) {
-        if (base._isE2eEncrypted) {
+        if (base.isE2eEncrypted()) {
             // renaming the encrypted folder is done via remove + re-upload hence we need to mark the newly created folder as encrypted
             // base is a record in the SyncJournal database that contains the data about the being-renamed folder with it's old name and encryption information
             item->_isEncrypted = true;
@@ -1551,7 +1551,7 @@ void ProcessDirectoryJob::processFileFinalize(
     if (recurse) {
         auto job = new ProcessDirectoryJob(path, item, recurseQueryLocal, recurseQueryServer,
             _lastSyncTimestamp, this);
-        job->setInsideEncryptedTree(isInsideEncryptedTree() || item->_isEncrypted);
+        job->setInsideEncryptedTree(isInsideEncryptedTree() || item->isEncrypted());
         if (removed) {
             job->setParent(_discoveryData);
             _discoveryData->enqueueDirectoryToDelete(path._original, job);
index e2ec41d855c90cc792db30937cdadb5433b65430..dc327b2374a16c07db9686c37e7fc07af6d3e5f9 100644 (file)
@@ -458,7 +458,7 @@ static void propertyMapToRemoteInfo(const QMap<QString, QString> &map, RemoteInf
                 result.sharedByMe = true;
             }
         } else if (property == "is-encrypted" && value == QStringLiteral("1")) {
-            result.isE2eEncrypted = true;
+            result._isE2eEncrypted = true;
         } else if (property == "lock") {
             result.locked = (value == QStringLiteral("1") ? SyncFileItem::LockStatus::LockedItem : SyncFileItem::LockStatus::UnlockedItem);
         }
@@ -576,7 +576,7 @@ void DiscoverySingleDirectoryJob::lsJobFinishedWithoutErrorSlot()
         emit finished(HttpError{ 0, _error });
         deleteLater();
         return;
-    } else if (_isE2eEncrypted) {
+    } else if (isE2eEncrypted()) {
         emit etag(_firstEtag, QDateTime::fromString(QString::fromUtf8(_lsColJob->responseTimestamp()), Qt::RFC2822Date));
         fetchE2eMetadata();
         return;
@@ -640,7 +640,7 @@ void DiscoverySingleDirectoryJob::metadataReceived(const QJsonDocument &json, in
         auto result = info;
         const auto encryptedFileInfo = findEncryptedFile(result.name);
         if (encryptedFileInfo) {
-            result.isE2eEncrypted = true;
+            result._isE2eEncrypted = true;
             result.e2eMangledName = _subPath.mid(1) + QLatin1Char('/') + result.name;
             result.name = encryptedFileInfo->originalFilename;
         }
index 61663925df18d0f9e32039b084369521160b3ec6..5f5a4223e46e78f7ab8a4608d2e80843b01651a7 100644 (file)
@@ -66,12 +66,13 @@ struct RemoteInfo
     int64_t size = 0;
     int64_t sizeOfFolder = 0;
     bool isDirectory = false;
-    bool isE2eEncrypted = false;
+    bool _isE2eEncrypted = false;
     bool isFileDropDetected = false;
     QString e2eMangledName;
     bool sharedByMe = false;
 
     [[nodiscard]] bool isValid() const { return !name.isNull(); }
+    [[nodiscard]] bool isE2eEncrypted() const { return _isE2eEncrypted; }
 
     QString directDownloadUrl;
     QString directDownloadCookies;
@@ -160,6 +161,9 @@ private slots:
     void metadataError(const QByteArray& fileId, int httpReturnCode);
 
 private:
+
+    [[nodiscard]] bool isE2eEncrypted() const { return _isE2eEncrypted; }
+
     QVector<RemoteInfo> _results;
     QString _subPath;
     QByteArray _firstEtag;
index f73c82cccb1dcad81ec54a790dd99fcb16bfc330..51510ad888b64f4045fae86d5d1335bb8e2c7eee 100644 (file)
@@ -326,7 +326,7 @@ bool PropagateItemJob::hasEncryptedAncestor() const
             qCWarning(lcPropagator) << "could not get file from local DB" << pathCompontentsJointed;
         }
 
-        if (rec.isValid() && rec._isE2eEncrypted) {
+        if (rec.isValid() && rec.isE2eEncrypted()) {
             return true;
         }
         pathComponents.removeLast();
@@ -1021,14 +1021,14 @@ bool OwncloudPropagator::isDelayedUploadItem(const SyncFileItemPtr &item) const
 
         if (!accountPtr->capabilities().clientSideEncryptionAvailable() ||
             !parentRec.isValid() ||
-            !parentRec._isE2eEncrypted) {
+            !parentRec.isE2eEncrypted()) {
             return false;
         }
 
         return true;
     };
 
-    return account()->capabilities().bulkUpload() && !_scheduleDelayedTasks && !item->_isEncrypted && _syncOptions._minChunkSize > item->_size && !isInBulkUploadBlackList(item->_file) && !checkFileShouldBeEncrypted(item);
+    return account()->capabilities().bulkUpload() && !_scheduleDelayedTasks && !item->isEncrypted() && _syncOptions._minChunkSize > item->_size && !isInBulkUploadBlackList(item->_file) && !checkFileShouldBeEncrypted(item);
 }
 
 void OwncloudPropagator::setScheduleDelayedTasks(bool active)
index 2bdc09b63737ddc661837bc1de4acdc76ee10d17..dd0525d225cbc253d335e8e725dece293ad04f6d 100644 (file)
@@ -199,7 +199,7 @@ public:
         // TODO: In fact, we must make sure Lock/Unlock are not colliding and always wait for each other to complete. So, we could refactor this "_parallelism" later
         // so every "PropagateItemJob" that will potentially execute Lock job on E2EE folder will get executed sequentially.
         // As an alternative, we could optimize Lock/Unlock calls, so we do a batch-write on one folder and only lock and unlock a folder once per batch.
-        _parallelism = (_item->_isEncrypted || hasEncryptedAncestor()) ? WaitForFinished : FullParallelism;
+        _parallelism = (_item->isEncrypted() || hasEncryptedAncestor()) ? WaitForFinished : FullParallelism;
     }
     ~PropagateItemJob() override;
 
index ead85459f979911057ba565fdc124e289cf73e86..970c8e246df3a1028cae5f24e1772e09295d73c3 100644 (file)
@@ -468,7 +468,7 @@ void PropagateDownloadFile::start()
     const auto account = propagator()->account();
     if (!account->capabilities().clientSideEncryptionAvailable() ||
         !parentRec.isValid() ||
-        !parentRec._isE2eEncrypted) {
+        !parentRec.isE2eEncrypted()) {
         startAfterIsEncryptedIsChecked();
     } else {
         _downloadEncryptedHelper = new PropagateDownloadEncrypted(propagator(), parentPath, _item, this);
@@ -718,7 +718,7 @@ void PropagateDownloadFile::startDownload()
     if (_item->_directDownloadUrl.isEmpty()) {
         // Normal job, download from oC instance
         _job = new GETFileJob(propagator()->account(),
-            propagator()->fullRemotePath(_isEncrypted ? _item->_encryptedFileName : _item->_file),
+            propagator()->fullRemotePath(isEncrypted() ? _item->_encryptedFileName : _item->_file),
             &_tmpFile, headers, expectedEtagForResume, _resumeStart, this);
     } else {
         // We were provided a direct URL, use that one
@@ -940,7 +940,7 @@ void PropagateDownloadFile::slotChecksumFail(const QString &errMsg,
 {
     if (reason == ValidateChecksumHeader::FailureReason::ChecksumMismatch && propagator()->account()->isChecksumRecalculateRequestSupported()) {
             const QByteArray calculatedChecksumHeader(calculatedChecksumType + ':' + calculatedChecksum);
-            const QString fullRemotePathForFile(propagator()->fullRemotePath(_isEncrypted ? _item->_encryptedFileName : _item->_file));
+            const QString fullRemotePathForFile(propagator()->fullRemotePath(isEncrypted() ? _item->_encryptedFileName : _item->_file));
             auto *job = new SimpleFileJob(propagator()->account(), fullRemotePathForFile);
             QObject::connect(job, &SimpleFileJob::finishedSignal, this,
                 [this, calculatedChecksumHeader, errMsg](const QNetworkReply *reply) { processChecksumRecalculate(reply, calculatedChecksumHeader, errMsg);
@@ -1137,7 +1137,7 @@ void PropagateDownloadFile::localFileContentChecksumComputed(const QByteArray &c
 
 void PropagateDownloadFile::finalizeDownload()
 {
-    if (_isEncrypted) {
+    if (isEncrypted()) {
         if (_downloadEncryptedHelper->decryptFile(_tmpFile)) {
             downloadFinished();
         } else {
@@ -1329,7 +1329,7 @@ void PropagateDownloadFile::updateMetadata(bool isConflict)
         return;
     }
 
-    if (_isEncrypted) {
+    if (isEncrypted()) {
         propagator()->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo());
     } else {
         propagator()->_journal->setDownloadInfo(_item->_encryptedFileName, SyncJournalDb::DownloadInfo());
index e6a7b133bf4becdb8f0f42ac1f375e8818ed4e76..2a5fea962ce50722ce5b688a47e9699b2b8698dd 100644 (file)
@@ -245,6 +245,7 @@ private slots:
 private:
     void startAfterIsEncryptedIsChecked();
     void deleteExistingFolder();
+    [[nodiscard]] bool isEncrypted() const { return _isEncrypted; }
 
     qint64 _resumeStart = 0;
     qint64 _downloadProgress = 0;
index ddf3f11f79c3c42b945084ebfde1f8cc8b475261..84aab6fe40af679be85ce07fba3ca3a35c71f44e 100644 (file)
@@ -33,7 +33,7 @@ void PropagateRemoteDelete::start()
     if (propagator()->_abortRequested)
         return;
 
-    if (!_item->_encryptedFileName.isEmpty() || _item->_isEncrypted) {
+    if (!_item->_encryptedFileName.isEmpty() || _item->isEncrypted()) {
         if (!_item->_encryptedFileName.isEmpty()) {
             _deleteEncryptedHelper = new PropagateRemoteDeleteEncrypted(propagator(), _item, this);
         } else {
index e8d86e30811287d5a61b9c1a208617fa75085eac..c9f82ee8e48ff55fe3db3a8a2a582273f8e0875c 100644 (file)
@@ -49,7 +49,7 @@ PropagateRemoteDeleteEncryptedRootFolder::PropagateRemoteDeleteEncryptedRootFold
 
 void PropagateRemoteDeleteEncryptedRootFolder::start()
 {
-    Q_ASSERT(_item->_isEncrypted);
+    Q_ASSERT(_item->isEncrypted());
 
     const bool listFilesResult = _propagator->_journal->listFilesInPath(_item->_file.toUtf8(), [this](const OCC::SyncJournalFileRecord &record) {
         _nestedItems[record._e2eMangledName] = record;
index 88401dbd5f14791dcfba1fe4c8ff6010d95cee6d..b4dc65b971dd56e9733c29ae840aa9bd06cc5a7d 100644 (file)
@@ -146,7 +146,7 @@ void PropagateRemoteMkdir::finalizeMkColJob(QNetworkReply::NetworkError err, con
         _item->_isShared = _item->_remotePerm.hasPermission(RemotePermissions::IsShared) || _item->_sharedByMe;
         _item->_lastShareStateFetchedTimestamp = QDateTime::currentMSecsSinceEpoch();
 
-        if (!_uploadEncryptedHelper && !_item->_isEncrypted) {
+        if (!_uploadEncryptedHelper && !_item->isEncrypted()) {
             success();
         } else {
             // We still need to mark that folder encrypted in case we were uploading it as encrypted one
index b834c024b035e9187247a7b7c5f30a002f9b74d5..6f70ce5db6239b4a91d22f62a4cc346d58fe742f 100644 (file)
@@ -219,7 +219,7 @@ void PropagateUploadFileCommon::start()
 
     if (!account->capabilities().clientSideEncryptionAvailable() ||
         !parentRec.isValid() ||
-        !parentRec._isE2eEncrypted) {
+        !parentRec.isE2eEncrypted()) {
         setupUnencryptedFile();
         return;
     }
index 1727a893890815acacf5c284e4321c63643f1f8e..135f3c63714bb486abf13678188f02a547686166 100644 (file)
@@ -49,7 +49,7 @@ SyncJournalFileRecord SyncFileItem::toSyncJournalFileRecordWithInode(const QStri
     rec._serverHasIgnoredFiles = _serverHasIgnoredFiles;
     rec._checksumHeader = _checksumHeader;
     rec._e2eMangledName = _encryptedFileName.toUtf8();
-    rec._isE2eEncrypted = _isEncrypted;
+    rec._isE2eEncrypted = isEncrypted();
     rec._lockstate._locked = _locked == LockStatus::LockedItem;
     rec._lockstate._lockOwnerDisplayName = _lockOwnerDisplayName;
     rec._lockstate._lockOwnerId = _lockOwnerId;
@@ -86,7 +86,7 @@ SyncFileItemPtr SyncFileItem::fromSyncJournalFileRecord(const SyncJournalFileRec
     item->_serverHasIgnoredFiles = rec._serverHasIgnoredFiles;
     item->_checksumHeader = rec._checksumHeader;
     item->_encryptedFileName = rec.e2eMangledName();
-    item->_isEncrypted = rec._isE2eEncrypted;
+    item->_isEncrypted = rec.isE2eEncrypted();
     item->_locked = rec._lockstate._locked ? LockStatus::LockedItem : LockStatus::UnlockedItem;
     item->_lockOwnerDisplayName = rec._lockstate._lockOwnerDisplayName;
     item->_lockOwnerId = rec._lockstate._lockOwnerId;
index 3890e339f1ce2d33c2a6ba3ad9a73978fe8a9ccb..4715901ab3c85c90632f206eae5a359c773e3da1 100644 (file)
@@ -228,6 +228,8 @@ public:
             && !(_instruction == CSYNC_INSTRUCTION_CONFLICT && _status == SyncFileItem::Success);
     }
 
+    [[nodiscard]] bool isEncrypted() const { return _isEncrypted; }
+
     // Variables useful for everybody
 
     /** The syncfolder-relative filesystem path that the operation is about
index e81f2bfb659fd5d4cac93ab0e9f42a7dad5f098a..2cd2afd49b261ddb5181a5414dcca8d859401d02 100644 (file)
@@ -130,7 +130,7 @@ private slots:
 
         SyncJournalFileRecord updatedRec;
         QVERIFY(folder->journalDb()->getFileRecord(QStringLiteral("encrypted"), &updatedRec));
-        QVERIFY(updatedRec._isE2eEncrypted);
+        QVERIFY(updatedRec.isE2eEncrypted());
         QVERIFY(updatedRec.isDirectory());
 
         FolderMan::instance()->removeE2eFiles(account);