Directly provide text file path to logger for debug archive creation

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-01-02 20:45:29 +08:00
parent b2e5659c43
commit 571b1ca238
No known key found for this signature in database
GPG key ID: C839200C384636B0
3 changed files with 8 additions and 7 deletions

View file

@ -50,9 +50,10 @@ extension Logger {
}
@available(macOSApplicationExtension 12.0, *)
static func createDebugArchive(saveFolderUrl: URL) {
let saveFileUrl = saveFolderUrl.appendingPathComponent("nc-fileprovider-debug.txt")
let saveFilePath = saveFolderUrl.path
static func createDebugArchive(saveFileURL: URL) {
let saveFilePath = saveFileURL.path
Logger.logger.info("Creating debug file at path \(saveFilePath, privacy: .public)")
guard FileManager.default.createFile(atPath: saveFilePath, contents: nil) else {
Logger.logger.error("Could not create log file")
@ -65,7 +66,7 @@ extension Logger {
}
for logString in logs {
try? logString.write(to: saveFileUrl, atomically: true, encoding: .utf8)
try? logString.write(to: saveFileURL, atomically: true, encoding: .utf8)
}
}
}

View file

@ -63,7 +63,7 @@ class ClientCommunicationService: NSObject, NSFileProviderServiceSource, NSXPCLi
func createDebugArchive(at url: URL!) {
if #available(macOSApplicationExtension 12.0, *) {
Logger.createDebugArchive(saveFolderUrl: url)
Logger.createDebugArchive(saveFileURL: url)
}
}
}

View file

@ -409,8 +409,8 @@ void FileProviderSettingsController::createDebugArchive(const QString &userIdAtH
{
const auto filename = QFileDialog::getSaveFileName(nullptr,
tr("Create Debug Archive"),
{},
tr("Zip Archives") + " (*.zip)");
QStandardPaths::writableLocation(QStandardPaths::StandardLocation::DocumentsLocation),
tr("Text files") + " (*.txt)");
if (filename.isEmpty()) {
return;
}