Present sharing of E2EE files from the main dialog too
authorKevin Ottens <kevin.ottens@nextcloud.com>
Thu, 20 Aug 2020 12:53:14 +0000 (14:53 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Thu, 20 Aug 2020 12:53:14 +0000 (14:53 +0200)
The visibility of the share button for the activity list is tied to the
path role in the ActivityListModel, so make sure we don't return a path
for E2EE files and folders.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/gui/tray/ActivityListModel.cpp

index f6c9a177855a9a7a3479e86bec0918e242fed830..ddfbd6fcdf28a55d6b3176fac2012aafb8ceaba2 100644 (file)
@@ -90,21 +90,36 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
         return QString();
     case PathRole:
         if (!a._file.isEmpty()) {
-            auto folder = FolderMan::instance()->folder(a._folder);
+            auto folder = FolderMan::instance()->folderForPath(a._folder);
+
             QString relPath(a._file);
             if (folder)
                 relPath.prepend(folder->remotePath());
             list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account());
-            if (list.count() > 0) {
-                return QUrl::fromLocalFile(list.at(0));
-            }
+
             // File does not exist anymore? Let's try to open its path
-            if (QFileInfo(relPath).exists()) {
+            if (list.isEmpty() && QFileInfo(relPath).exists()) {
                 list = FolderMan::instance()->findFileInLocalFolders(QFileInfo(relPath).path(), ast->account());
-                if (list.count() > 0) {
-                    return QVariant(list.at(0));
+            }
+
+            if (list.isEmpty()) {
+                return QString();
+            }
+
+            const auto path = list.at(0);
+            folder = FolderMan::instance()->folderForPath(path);
+
+            // If this is an E2EE file or folder, pretend we got no path, this leads to
+            // hiding the share button which is what we want
+            if (folder) {
+                SyncJournalFileRecord rec;
+                folder->journalDb()->getFileRecord(a._file.mid(1), &rec);
+                if (rec.isValid() && (rec._isE2eEncrypted || !rec._e2eMangledName.isEmpty())) {
+                    return QString();
                 }
             }
+
+            return QUrl::fromLocalFile(path);
         }
         return QString();
     case AbsolutePathRole: {