From: Claudio Cambra Date: Wed, 3 Jan 2024 09:16:10 +0000 (+0800) Subject: Create debug archive on client side X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~7^2~140^2~38 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=62bbf6a2ad5143f3b2d4274a3d084b6e49362fb3;p=nextcloud-desktop.git Create debug archive on client side Signed-off-by: Claudio Cambra --- diff --git a/src/gui/macOS/fileproviderxpc_mac.mm b/src/gui/macOS/fileproviderxpc_mac.mm index 22cd6ab60..260804b71 100644 --- a/src/gui/macOS/fileproviderxpc_mac.mm +++ b/src/gui/macOS/fileproviderxpc_mac.mm @@ -104,9 +104,37 @@ void FileProviderXPC::slotAccountStateChanged(const AccountState::State state) c } void FileProviderXPC::createDebugArchiveForExtension(const QString &extensionAccountId, const QString &filename) const { + qCInfo(lcFileProviderXPC) << "Creating debug archive for extension" << extensionAccountId << "at" << filename; + // You need to fetch the contents from the extension and then create the archive from the client side. + // The extension is not allowed to ask for permission to write into the file system as it is not a user facing process. const auto clientCommService = (NSObject *)_clientCommServices.value(extensionAccountId); - NSURL *const fileURL = [NSURL fileURLWithPath:filename.toNSString()]; - [clientCommService createDebugArchiveAtURL:fileURL]; + const auto group = dispatch_group_create(); + __block NSString *rcvdDebugLogString; + dispatch_group_enter(group); + [clientCommService createDebugLogStringWithCompletionHandler:^(NSString *const debugLogString, NSError *const error) { + if (error != nil) { + qCWarning(lcFileProviderXPC) << "Error getting debug log string" << error.localizedDescription; + dispatch_group_leave(group); + return; + } else if (debugLogString == nil) { + qCWarning(lcFileProviderXPC) << "Debug log string is nil"; + dispatch_group_leave(group); + return; + } + rcvdDebugLogString = [NSString stringWithString:debugLogString]; + [rcvdDebugLogString retain]; + dispatch_group_leave(group); + }]; + dispatch_group_wait(group, DISPATCH_TIME_FOREVER); + + QFile debugLogFile(filename); + if (debugLogFile.open(QIODevice::WriteOnly)) { + debugLogFile.write(rcvdDebugLogString.UTF8String); + debugLogFile.close(); + qCInfo(lcFileProviderXPC) << "Debug log file written to" << filename; + } else { + qCWarning(lcFileProviderXPC) << "Could not open debug log file" << filename; + } } } // namespace OCC::Mac