diff options
author | Claudio Cambra <claudio.cambra@gmail.com> | 2022-03-20 01:30:59 +0300 |
---|---|---|
committer | Claudio Cambra <claudio.cambra@gmail.com> | 2022-03-20 01:31:24 +0300 |
commit | 98e297bf0b4f1ffae3a70ace9e0fbecbb5eb97a6 (patch) | |
tree | ba3db3b3b2c2abbadc3cc6e2afa4fa6012be72cd /src | |
parent | d99a65f017082c60a051fe47240afaedce4d6171 (diff) |
Fix for VFS crashes
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/tray/usermodel.cpp | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 0a4eb632c..1298fc627 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -551,33 +551,38 @@ void User::processCompletedSyncItem(const Folder *folder, const SyncFileItemPtr activity._message = messageFromFileAction(activity._fileAction, fileName); } - if(activity._fileAction != "file_deleted") { + if(activity._fileAction != "file_deleted" && !item->isEmpty()) { auto remotePath = folder->remotePath(); remotePath.append(activity._fileAction == "file_renamed" ? item->_renameTarget : activity._file); const auto localFiles = FolderMan::instance()->findFileInLocalFolders(item->_file, account()); if (!localFiles.isEmpty()) { - const QMimeType mimeType = _mimeDb.mimeTypeForFile(QFileInfo(localFiles.constFirst())); - - // Set the preview data, though for now we can skip setting file ID, link, and view - PreviewData preview; - preview._mimeType = mimeType.name(); - preview._filename = fileName; - - if(item->isDirectory()) { - preview._source = account()->url().toString() + QStringLiteral("/index.php/apps/theming/img/core/filetypes/folder.svg"); - preview._isMimeTypeIcon = true; - } else if(mimeType.isValid() && mimeType.inherits("text/plain")) { - preview._source = account()->url().toString() + QStringLiteral("/index.php/apps/theming/img/core/filetypes/text.svg"); - preview._isMimeTypeIcon = true; - } else if (mimeType.isValid() && mimeType.inherits("application/pdf")) { - preview._source = account()->url().toString() + QStringLiteral("/index.php/apps/theming/img/core/filetypes/application-pdf.svg"); - preview._isMimeTypeIcon = true; - } else { - preview._source = account()->url().toString() + QStringLiteral("/index.php/apps/files/api/v1/thumbnail/150/150/") + remotePath; - preview._isMimeTypeIcon = false; + const auto firstFilePath = localFiles.constFirst(); + const auto itemJournalRecord = item->toSyncJournalFileRecordWithInode(firstFilePath); + + if(!itemJournalRecord.isVirtualFile()) { + const auto mimeType = _mimeDb.mimeTypeForFile(QFileInfo(localFiles.constFirst())); + + // Set the preview data, though for now we can skip setting file ID, link, and view + PreviewData preview; + preview._mimeType = mimeType.name(); + preview._filename = fileName; + + if(item->isDirectory()) { + preview._source = account()->url().toString() + QStringLiteral("/index.php/apps/theming/img/core/filetypes/folder.svg"); + preview._isMimeTypeIcon = true; + } else if(mimeType.isValid() && mimeType.inherits("text/plain")) { + preview._source = account()->url().toString() + QStringLiteral("/index.php/apps/theming/img/core/filetypes/text.svg"); + preview._isMimeTypeIcon = true; + } else if (mimeType.isValid() && mimeType.inherits("application/pdf")) { + preview._source = account()->url().toString() + QStringLiteral("/index.php/apps/theming/img/core/filetypes/application-pdf.svg"); + preview._isMimeTypeIcon = true; + } else { + preview._source = account()->url().toString() + QStringLiteral("/index.php/apps/files/api/v1/thumbnail/150/150/") + remotePath; + preview._isMimeTypeIcon = false; + } + activity._previews.append(preview); } - activity._previews.append(preview); } } |