Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle macOS File Provider module logs into main debug archive #7464

Merged
merged 6 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -12,7 +12,7 @@
* for more details.
*/

#include <QObject>

Check failure on line 15 in src/gui/macOS/fileproviderxpc.h

View workflow job for this annotation

GitHub Actions / build

src/gui/macOS/fileproviderxpc.h:15:10 [clang-diagnostic-error]

'QObject' file not found
#include <QHash>
#include <QDateTime>

Expand Down Expand Up @@ -45,7 +45,7 @@
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
Loading