}
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<ClientCommunicationProtocol> *)_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