From 15d6d6f1c8aa08ed7fa215ec23ada81cec3bee80 Mon Sep 17 00:00:00 2001 From: alex-z Date: Fri, 19 Jan 2024 12:55:31 +0100 Subject: [PATCH] Do not allow sharing on version less than 2.0. Signed-off-by: alex-z --- src/gui/filedetails/ShareView.qml | 2 +- src/gui/filedetails/ShareeSearchField.qml | 2 +- src/gui/filedetails/sharemodel.cpp | 20 ++++---------------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/gui/filedetails/ShareView.qml b/src/gui/filedetails/ShareView.qml index 6f2162c4dc692..64a8394c08dcd 100644 --- a/src/gui/filedetails/ShareView.qml +++ b/src/gui/filedetails/ShareView.qml @@ -146,7 +146,7 @@ ColumnLayout { Layout.rightMargin: root.horizontalPadding visible: root.userGroupSharingPossible - enabled: visible && !root.loading && !root.shareModel.isShareDisabledFolder + enabled: visible && !root.loading && !root.shareModel.isShareDisabledFolder && !shareeSearchField.isShareeFetchOngoing accountState: root.accountState shareItemIsFolder: root.fileDetails && root.fileDetails.isFolder diff --git a/src/gui/filedetails/ShareeSearchField.qml b/src/gui/filedetails/ShareeSearchField.qml index dd06ed1738fbe..300b9c36004b5 100644 --- a/src/gui/filedetails/ShareeSearchField.qml +++ b/src/gui/filedetails/ShareeSearchField.qml @@ -29,6 +29,7 @@ TextField { property var accountState: ({}) property bool shareItemIsFolder: false property var shareeBlocklist: ({}) + property bool isShareeFetchOngoing: shareeModel.fetchOngoing property ShareeModel shareeModel: ShareeModel { accountState: root.accountState shareItemIsFolder: root.shareItemIsFolder @@ -46,7 +47,6 @@ TextField { placeholderText: enabled ? qsTr("Search for users or groups…") : qsTr("Sharing is not available for this folder") placeholderTextColor: placeholderColor - enabled: !shareeModel.fetchOngoing onActiveFocusChanged: triggerSuggestionsVisibility() onTextChanged: triggerSuggestionsVisibility() diff --git a/src/gui/filedetails/sharemodel.cpp b/src/gui/filedetails/sharemodel.cpp index 6038ef019f15e..71a4b47156854 100644 --- a/src/gui/filedetails/sharemodel.cpp +++ b/src/gui/filedetails/sharemodel.cpp @@ -278,21 +278,9 @@ void ShareModel::updateData() _sharedItemType = fileRecord.isE2eEncrypted() ? SharedItemType::SharedItemTypeEncryptedFile : SharedItemType::SharedItemTypeFile; } - if (_sharedItemType == SharedItemType::SharedItemTypeEncryptedTopLevelFolder && - fileRecord._e2eEncryptionStatus >= SyncJournalFileRecord::EncryptionStatus::EncryptedMigratedV2_0) { - int numFoldersInPath = 0; - const auto listFoldersInPathCallback = [&numFoldersInPath](const SyncJournalFileRecord &record) { - if (record.isValid() && record.isDirectory()) { - ++numFoldersInPath; - } - }; - const bool listFoldersInPathSucceeded = _folder->journalDb()->listFilesInPath(fileRecord.path().toUtf8(), listFoldersInPathCallback); - const auto wasShareDisabledForFolder = _isShareDisabledFolder; - _isShareDisabledFolder = listFoldersInPathSucceeded && numFoldersInPath > 0; - if (_isShareDisabledFolder != wasShareDisabledForFolder) { - emit isShareDisabledFolderChanged(); - } - } + _isShareDisabledFolder = fileRecord.isE2eEncrypted() + && (_sharedItemType != SharedItemType::SharedItemTypeEncryptedTopLevelFolder + || fileRecord._e2eEncryptionStatus < SyncJournalFileRecord::EncryptionStatus::EncryptedMigratedV2_0); // Will get added when shares are fetched if no link shares are fetched _placeholderLinkShare.reset(new Share(_accountState->account(), @@ -1321,7 +1309,7 @@ bool ShareModel::serverAllowsResharing() const bool ShareModel::isShareDisabledFolder() const { - return false; + return _isShareDisabledFolder; } QVariantList ShareModel::sharees() const