Skip to content

Commit 1534ff2

Browse files
committed
fix(file-provider): Consolidated support and log directories.
Signed-off-by: Iva Horn <[email protected]>
1 parent b2ef402 commit 1534ff2

File tree

3 files changed

+12
-47
lines changed

3 files changed

+12
-47
lines changed

src/gui/generalsettings.cpp

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -152,46 +152,25 @@ bool createDebugArchive(const QString &filename)
152152
}
153153

154154
#ifdef BUILD_FILE_PROVIDER_MODULE
155-
qDebug() << "Trying to add file provider domain log files...";
156-
const auto fileProviderExtensionLogDirectory = OCC::Mac::FileProviderUtils::fileProviderExtensionLogDirectory();
157-
158-
if (fileProviderExtensionLogDirectory.exists()) {
159-
// Recursively add all files from the container log directory
160-
QDirIterator it(fileProviderExtensionLogDirectory.path(), QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
161-
162-
while (it.hasNext()) {
163-
const auto logFilePath = it.next();
164-
165-
// Calculate relative path from the base container log directory
166-
const auto relativePath = fileProviderExtensionLogDirectory.relativeFilePath(logFilePath);
167-
const auto zipPath = QStringLiteral("File Provider Domains/%1").arg(relativePath);
168-
169-
zip.addLocalFile(logFilePath, zipPath);
170-
}
171-
172-
qDebug() << "Added file provider domain log files from" << fileProviderExtensionLogDirectory.path();
173-
} else {
174-
qWarning() << "file provider domain container log directory not found at" << fileProviderExtensionLogDirectory.path();
175-
}
176-
177-
qDebug() << "Trying to add file provider database files...";
155+
qDebug() << "Trying to add file provider domain database and log files...";
178156
const auto fileProviderDomainsSupportDirectory = OCC::Mac::FileProviderUtils::fileProviderDomainsSupportDirectory();
179157

180158
if (fileProviderDomainsSupportDirectory.exists()) {
181-
QDirIterator it(fileProviderDomainsSupportDirectory.path(), QStringList() << "*.realm", QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
159+
// Recursively add all files from the container log directory
160+
QDirIterator it(fileProviderDomainsSupportDirectory.path(), QStringList() << "*.jsonl" << "*.realm", QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
182161

183162
while (it.hasNext()) {
184-
const auto dbFilePath = it.next();
163+
const auto filePath = it.next();
185164

186-
// Calculate relative path from the base domains support directory
187-
const auto relativePath = fileProviderDomainsSupportDirectory.relativeFilePath(dbFilePath);
165+
// Calculate relative path from the base container log directory
166+
const auto relativePath = fileProviderDomainsSupportDirectory.relativeFilePath(filePath);
188167
const auto zipPath = QStringLiteral("File Provider Domains/%1").arg(relativePath);
189168

190-
zip.addLocalFile(dbFilePath, zipPath);
191-
qDebug() << "Added file provider domain database file from" << dbFilePath;
169+
zip.addLocalFile(filePath, zipPath);
170+
qDebug() << "Added file from" << filePath;
192171
}
193172
} else {
194-
qWarning() << "file provider domains support directory not found at" << fileProviderDomainsSupportDirectory.path();
173+
qWarning() << "file provider domain container log directory not found at" << fileProviderDomainsSupportDirectory.path();
195174
}
196175
#endif
197176

src/gui/macOS/fileproviderutils.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ QString domainIdentifierForAccountIdentifier(const NSString *accountId);
103103
*/
104104
bool illegalDomainIdentifier(const QString &domainId);
105105

106-
/**
107-
* @brief Find the logs directory of the file provider extension for all the domains.
108-
*/
109-
QDir fileProviderExtensionLogDirectory();
110-
111106
/**
112107
* @brief Find the logs directory of the file provider domain with the given identifier.
113108
*/

src/gui/macOS/fileproviderutils_mac.mm

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,10 @@ QString applicationGroupContainer()
148148
return QString::fromNSString([NSFileManager.defaultManager containerURLForSecurityApplicationGroupIdentifier:groupId].path);
149149
}
150150

151-
QDir fileProviderExtensionLogDirectory()
152-
{
153-
auto applicationGroupContainerPath = applicationGroupContainer();
154-
auto logsPath = applicationGroupContainerPath + "/Library/Logs/File Provider Domains";
155-
auto directory = QDir(logsPath);
156-
157-
return directory;
158-
}
159-
160151
QDir fileProviderDomainLogDirectory(const QString domainIdentifier)
161152
{
162-
auto logsDirectory = fileProviderExtensionLogDirectory();
163-
auto domainLogsPath = logsDirectory.filePath(domainIdentifier);
153+
auto logsDirectory = fileProviderDomainSupportDirectory(domainIdentifier);
154+
auto domainLogsPath = logsDirectory.filePath("Logs");
164155
auto directory = QDir(domainLogsPath);
165156

166157
return directory;
@@ -169,7 +160,7 @@ QDir fileProviderDomainLogDirectory(const QString domainIdentifier)
169160
QDir fileProviderDomainsSupportDirectory()
170161
{
171162
auto applicationGroupContainerPath = applicationGroupContainer();
172-
auto supportPath = applicationGroupContainerPath + "/Library/Application Support/File Provider Domains";
163+
auto supportPath = applicationGroupContainerPath + "/File Provider Domains";
173164
auto directory = QDir(supportPath);
174165

175166
return directory;

0 commit comments

Comments
 (0)