Share dialog: use the original name and not the virtual file name
authorOlivier Goffart <ogoffart@woboq.com>
Mon, 28 May 2018 15:14:57 +0000 (17:14 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:57:54 +0000 (10:57 +0100)
When sharing a virtual file, we should actually use the original file name
not the virtual file name

Issue: #6461

src/gui/sharedialog.cpp
src/gui/socketapi.cpp
src/gui/socketapi.h

index cffb4e79637878e00c882fcacf0ef5488cd42baa..5ef8984aea7f4871c5a9043dad660b319429fb60 100644 (file)
@@ -87,8 +87,7 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState,
     }
 
     // Set filename
-    QFileInfo lPath(_localPath);
-    QString fileName = lPath.fileName();
+    QString fileName = QFileInfo(_sharePath).fileName();
     _ui->label_name->setText(tr("%1").arg(fileName));
     QFont f(_ui->label_name->font());
     f.setPointSize(qRound(f.pointSize() * 1.4));
index 04acddae88a97cd110447ec07c3f8b12f35ddb9f..a8d381c92b934d725e5c4d1a274d40ec980fa682 100644 (file)
@@ -864,7 +864,10 @@ SocketApi::FileData SocketApi::FileData::get(const QString &localFile)
 
     data.folderRelativePath = data.localPath.mid(data.folder->cleanPath().length() + 1);
     data.accountRelativePath = QDir(data.folder->remotePath()).filePath(data.folderRelativePath);
-
+    QString virtualFileExt = QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX);
+    if (data.accountRelativePath.endsWith(virtualFileExt)) {
+        data.accountRelativePath.chop(virtualFileExt.size());
+    }
     return data;
 }
 
index cb5c357fd750d50406940081fb0785799d09f660..c97a1ee7a163d26967bf222c9b94fbdd4a57d584 100644 (file)
@@ -82,8 +82,11 @@ private:
         FileData parentFolder() const;
 
         Folder *folder;
+        // Absolute path of the file locally. (May be a virtual file)
         QString localPath;
+        // Relative path of the file locally, as in the DB. (May be a virtual file)
         QString folderRelativePath;
+        // Path of the file on the server (In case of virtual file, it points to the actual file)
         QString accountRelativePath;
     };