Skip to content

Commit

Permalink
Merge pull request #6688 from nextcloud/backport/6598/stable-3.12
Browse files Browse the repository at this point in the history
Backport/6598/stable 3.12
  • Loading branch information
allexzander authored Apr 25, 2024
2 parents 3abef9c + a4f2130 commit 0ccc68c
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,19 @@ QVector<ZipEntry> createDebugArchiveFileList()
return list;
}

void createDebugArchive(const QString &filename)
bool 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 false;
}

const auto entries = createDebugArchiveFileList();

KZip zip(filename);
Expand All @@ -127,7 +138,9 @@ void createDebugArchive(const QString &filename)
zip.prepareWriting("__nextcloud_client_buildinfo.txt", {}, {}, buildInfo.size());
zip.writeData(buildInfo, buildInfo.size());
zip.finishWriting(buildInfo.size());
return true;
}

}

namespace OCC {
Expand Down Expand Up @@ -498,13 +511,24 @@ void GeneralSettings::slotIgnoreFilesEditor()

void GeneralSettings::slotCreateDebugArchive()
{
const auto filename = QFileDialog::getSaveFileName(this, tr("Create Debug Archive"), QString(), tr("Zip Archives") + " (*.zip)");
const auto filename = QFileDialog::getSaveFileName(
this,
tr("Create Debug Archive"),
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation),
tr("Zip Archives") + " (*.zip)"
);

if (filename.isEmpty()) {
return;
}

createDebugArchive(filename);
QMessageBox::information(this, tr("Debug Archive Created"), tr("Debug archive is created at %1").arg(filename));
if (createDebugArchive(filename)) {
QMessageBox::information(
this,
tr("Debug Archive Created"),
tr("Debug archive is created at %1").arg(filename)
);
}
}

void GeneralSettings::slotShowLegalNotice()
Expand Down

0 comments on commit 0ccc68c

Please sign in to comment.