Don't look at virtual files data for the mimetype matches
authorKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 29 Dec 2020 14:11:33 +0000 (15:11 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 30 Dec 2020 08:44:58 +0000 (09:44 +0100)
Otherwise this would attempt to download the file everytime we check the
direct editor for a given file which wouldn't be adequate. Would also
lead to a deadlock in our case since that would happen in the main
thread and implicit hydration is driven from there as well.

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

index 3be2d1455c09d06e84659705647e00b3002308b3..b1b4e7eaa7efaf4dcf8d215cdc177311f586fe98 100644 (file)
@@ -1178,8 +1178,11 @@ DirectEditor* SocketApi::getDirectEditorForLocalFile(const QString &localFile)
     auto capabilities = fileData.folder->accountState()->account()->capabilities();
 
     if (fileData.folder && fileData.folder->accountState()->isConnected()) {
+        const auto record = fileData.journalRecord();
+        const auto mimeMatchMode = record.isVirtualFile() ? QMimeDatabase::MatchExtension : QMimeDatabase::MatchDefault;
+
         QMimeDatabase db;
-        QMimeType type = db.mimeTypeForFile(localFile);
+        QMimeType type = db.mimeTypeForFile(localFile, mimeMatchMode);
 
         DirectEditor* editor = capabilities.getDirectEditorForMimetype(type);
         if (!editor) {