Skip to content

Commit 0ccc68c

Browse files
authored
Merge pull request #6688 from nextcloud/backport/6598/stable-3.12
Backport/6598/stable 3.12
2 parents 3abef9c + a4f2130 commit 0ccc68c

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/gui/generalsettings.cpp

+28-4
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,19 @@ QVector<ZipEntry> createDebugArchiveFileList()
107107
return list;
108108
}
109109

110-
void createDebugArchive(const QString &filename)
110+
bool createDebugArchive(const QString &filename)
111111
{
112+
const auto fileInfo = QFileInfo(filename);
113+
const auto dirInfo = QFileInfo(fileInfo.dir().absolutePath());
114+
if (!dirInfo.isWritable()) {
115+
QMessageBox::critical(
116+
nullptr,
117+
QObject::tr("Failed to create debug archive"),
118+
QObject::tr("Could not create debug archive in selected location!")
119+
);
120+
return false;
121+
}
122+
112123
const auto entries = createDebugArchiveFileList();
113124

114125
KZip zip(filename);
@@ -127,7 +138,9 @@ void createDebugArchive(const QString &filename)
127138
zip.prepareWriting("__nextcloud_client_buildinfo.txt", {}, {}, buildInfo.size());
128139
zip.writeData(buildInfo, buildInfo.size());
129140
zip.finishWriting(buildInfo.size());
141+
return true;
130142
}
143+
131144
}
132145

133146
namespace OCC {
@@ -498,13 +511,24 @@ void GeneralSettings::slotIgnoreFilesEditor()
498511

499512
void GeneralSettings::slotCreateDebugArchive()
500513
{
501-
const auto filename = QFileDialog::getSaveFileName(this, tr("Create Debug Archive"), QString(), tr("Zip Archives") + " (*.zip)");
514+
const auto filename = QFileDialog::getSaveFileName(
515+
this,
516+
tr("Create Debug Archive"),
517+
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation),
518+
tr("Zip Archives") + " (*.zip)"
519+
);
520+
502521
if (filename.isEmpty()) {
503522
return;
504523
}
505524

506-
createDebugArchive(filename);
507-
QMessageBox::information(this, tr("Debug Archive Created"), tr("Debug archive is created at %1").arg(filename));
525+
if (createDebugArchive(filename)) {
526+
QMessageBox::information(
527+
this,
528+
tr("Debug Archive Created"),
529+
tr("Debug archive is created at %1").arg(filename)
530+
);
531+
}
508532
}
509533

510534
void GeneralSettings::slotShowLegalNotice()

0 commit comments

Comments
 (0)