Ensure we are checking for tags in correct server path regardless of the particular...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 21 Oct 2024 06:57:22 +0000 (14:57 +0800)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 21 Nov 2024 08:57:39 +0000 (09:57 +0100)
Fixes issues with users who are using remote non-root sync folders

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/filedetails/filedetails.cpp
src/gui/filetagmodel.cpp
src/gui/filetagmodel.h

index 2b76c70ad296e76443ab6ceff5541e4da31a5ce1..9ebe8fac2bc1a31c9548efa8056401981160c1b8 100644 (file)
@@ -170,11 +170,7 @@ FileTagModel *FileDetails::fileTagModel() const
 
 void FileDetails::updateFileTagModel(const AccountPtr &account)
 {
-    Q_ASSERT(account);
-
-    const auto serverRelPath = QString(folder->remotePathTrailingSlash() + name());
-
-    _fileTagModel = std::make_unique<FileTagModel>(serverRelPath, account);
+    _fileTagModel = std::make_unique<FileTagModel>(_fileRecord, _folder, account);
     Q_EMIT fileTagModelChanged();
 }
 
index 64cab4486a4f98ce6c925910c986e94cfffad401..282ff84c1884817539eede4417cab74684d95140 100644 (file)
@@ -20,13 +20,21 @@ Q_LOGGING_CATEGORY(lcFileTagModel, "nextcloud.gui.filetagmodel", QtInfoMsg)
 
 namespace OCC {
 
-FileTagModel::FileTagModel(const QString &serverRelativePath,
+FileTagModel::FileTagModel(const SyncJournalFileRecord &fileRecord,
+                           const Folder * const syncFolder,
                            const AccountPtr &account,
                            QObject * const parent)
     : QAbstractListModel(parent)
-    , _serverRelativePath(serverRelativePath)
     , _account(account)
 {
+    _serverRelativePath = syncFolder->remotePathTrailingSlash() + fileRecord.path();
+
+    if (const auto vfsMode = syncFolder->vfs().mode(); fileRecord.isVirtualFile() && vfsMode == Vfs::WithSuffix) {
+        if (const auto suffix = syncFolder->vfs().fileSuffix(); !suffix.isEmpty() && _serverRelativePath.endsWith(suffix)) {
+            _serverRelativePath.chop(suffix.length());
+        }
+    }
+
     fetchFileTags();
 }
 
index 618702e8b5b09d802dfd4f24a71081bc7b7369b1..77933eccd98418cff056c266df7ac554eaade101 100644 (file)
@@ -16,6 +16,8 @@
 
 #include <QAbstractListModel>
 
+#include "common/syncjournalfilerecord.h"
+#include "gui/folder.h"
 #include "libsync/account.h"
 
 namespace OCC {
@@ -31,7 +33,10 @@ class FileTagModel : public QAbstractListModel
     Q_PROPERTY(QString overflowTagsString READ overflowTagsString NOTIFY overflowTagsStringChanged)
 
 public:
-    explicit FileTagModel(const QString &serverRelativePath, const AccountPtr &account, QObject * const parent = nullptr);
+    explicit FileTagModel(const SyncJournalFileRecord &fileRecord,
+                          const Folder *const syncFolder,
+                          const AccountPtr &account,
+                          QObject *const parent = nullptr);
 
     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
     [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;