Skip to content

Commit

Permalink
Merge pull request #7464 from nextcloud/bugfix/debug-archive-aio
Browse files Browse the repository at this point in the history
Bundle macOS File Provider module logs into main debug archive
  • Loading branch information
mgallien authored Nov 22, 2024
2 parents f1c6b65 + a69a9a3 commit 14581d2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
26 changes: 26 additions & 0 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
#endif
#endif

#ifdef BUILD_FILE_PROVIDER_MODULE
#include "macOS/fileprovider.h"
#include "macOS/fileprovidersettingscontroller.h"
#endif

#include "ignorelisteditor.h"
#include "common/utility.h"
#include "logger.h"
Expand Down Expand Up @@ -138,6 +143,27 @@ bool createDebugArchive(const QString &filename)
zip.addLocalFile(entry.localFilename, entry.zipFilename);
}

#ifdef BUILD_FILE_PROVIDER_MODULE
const auto fileProvider = OCC::Mac::FileProvider::instance();
if (fileProvider && fileProvider->fileProviderAvailable()) {
const auto tempDir = QTemporaryDir();
const auto xpc = fileProvider->xpc();
const auto vfsAccounts = OCC::Mac::FileProviderSettingsController::instance()->vfsEnabledAccounts();
for (const auto &accountUserIdAtHost : vfsAccounts) {
const auto accountState = OCC::AccountManager::instance()->accountFromUserId(accountUserIdAtHost);
if (!accountState) {
qWarning() << "Could not find account for" << accountUserIdAtHost;
continue;
}
const auto account = accountState->account();
const auto vfsLogFilename = QStringLiteral("macOS_vfs_%1.log").arg(account->davUser());
const auto vfsLogPath = tempDir.filePath(vfsLogFilename);
xpc->createDebugArchiveForExtension(accountUserIdAtHost, vfsLogPath);
zip.addLocalFile(vfsLogPath, vfsLogFilename);
}
}
#endif

const auto clientParameters = QCoreApplication::arguments().join(' ').toUtf8();
zip.prepareWriting("__nextcloud_client_parameters.txt", {}, {}, clientParameters.size());
zip.writeData(clientParameters, clientParameters.size());
Expand Down
2 changes: 1 addition & 1 deletion src/gui/macOS/fileproviderxpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public slots:
void configureExtensions();
void authenticateExtension(const QString &extensionAccountId) const;
void unauthenticateExtension(const QString &extensionAccountId) const;
void createDebugArchiveForExtension(const QString &extensionAccountId, const QString &filename) const;
void createDebugArchiveForExtension(const QString &extensionAccountId, const QString &filename);

void setFastEnumerationEnabledForExtension(const QString &extensionAccountId, bool enabled) const;

Expand Down
6 changes: 5 additions & 1 deletion src/gui/macOS/fileproviderxpc_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@
break;
}
}
void FileProviderXPC::createDebugArchiveForExtension(const QString &extensionAccountId, const QString &filename) const
void FileProviderXPC::createDebugArchiveForExtension(const QString &extensionAccountId, const QString &filename)
{
qCInfo(lcFileProviderXPC) << "Creating debug archive for extension" << extensionAccountId << "at" << filename;
if (!fileProviderExtReachable(extensionAccountId)) {
qCWarning(lcFileProviderXPC) << "Extension is not reachable. Cannot create debug archive";
return;
}
// 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);
Expand Down
5 changes: 0 additions & 5 deletions src/gui/macOS/ui/FileProviderSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ Page {
text: qsTr("Signal file provider domain")
onClicked: root.controller.signalFileProviderDomain(root.accountUserIdAtHost)
}

Button {
text: qsTr("Create debug archive")
onClicked: root.controller.createDebugArchive(root.accountUserIdAtHost)
}
}
}
}
Expand Down

0 comments on commit 14581d2

Please sign in to comment.