Prevent crash on creating debug archive in non-writeable location
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 1 Apr 2024 09:59:25 +0000 (17:59 +0800)
committerCamila Ayres <hello@camilasan.com>
Tue, 23 Apr 2024 18:20:49 +0000 (20:20 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/generalsettings.cpp

index 7598d94376c52bc203626b1f071dd24cf3012ae4..4d86c7c06d2601d1be6dbd1f4c9b6d830441daa5 100644 (file)
@@ -109,6 +109,17 @@ QVector<ZipEntry> createDebugArchiveFileList()
 
 void createDebugArchive(const QString &filename)
 {
+    const auto fileInfo = QFileInfo(filename);
+    const auto dirInfo = QFileInfo(fileInfo.dir().absolutePath());
+    if (!dirInfo.isWritable()) {
+        QMessageBox::critical(
+            nullptr,
+            QObject::tr("Failed to create debug archive"),
+            QObject::tr("Could not create debug archive in selected location!")
+        );
+        return;
+    }
+
     const auto entries = createDebugArchiveFileList();
 
     KZip zip(filename);