Merge pull request #8942 from nextcloud/backport/8941/stable-4.0

[stable-4.0] Fix Crash on File Provider Deactivation for Account with UUID Name
This commit is contained in:
Jyrki Gadinger 2025-10-23 15:52:10 +02:00 committed by GitHub
commit 43c53d02ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 18 deletions

View File

@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objectVersion = 70;
objects = {
/* Begin PBXBuildFile section */
@ -224,6 +224,10 @@
C2B573F11B1DAD6400303B36 /* warning.iconset */ = {isa = PBXFileReference; lastKnownFileType = folder.iconset; name = warning.iconset; path = ../../icons/nopadding/warning.iconset; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedRootGroup section */
AAD7F6032EAA11670071D385 /* gui */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); name = gui; path = /Users/iva/Projekte/nextcloud/desktop/src/gui; sourceTree = "<absolute>"; };
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
538E396427F4765000FA63D5 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
@ -403,6 +407,7 @@
C2B573941B1CD88000303B36 = {
isa = PBXGroup;
children = (
AAD7F6032EAA11670071D385 /* gui */,
AA27A4E32E93C0D700665051 /* README.md */,
C2B573B31B1CD91E00303B36 /* desktopclient */,
AA0A6B1C2E8EA948007F4A7A /* NextcloudDev */,

View File

@ -591,7 +591,7 @@ public:
}
}
QStringList configuredDomainIds() const
QStringList getAccountIdsOfFoundFileProviderDomains() const
{
return _registeredDomains.keys();
}
@ -652,34 +652,36 @@ void FileProviderDomainManager::updateFileProviderDomains()
return;
}
const auto vfsEnabledAccounts = FileProviderSettingsController::instance()->vfsEnabledAccounts();
auto configuredDomains = d->configuredDomainIds();
const auto fileProviderEnabledAccountIds = FileProviderSettingsController::instance()->vfsEnabledAccounts();
auto accountIdsOfFoundFileProviderDomains = d->getAccountIdsOfFoundFileProviderDomains();
for (const auto &accountUserIdAtHost : vfsEnabledAccounts) {
// If the domain has already been set up for this account, then don't set it up again
if (configuredDomains.contains(accountUserIdAtHost)) {
configuredDomains.removeAll(accountUserIdAtHost);
for (const auto &fileProviderEnabledAccountId : fileProviderEnabledAccountIds) {
// If the domain has already been set up for this account, then don't set it up again.
if (accountIdsOfFoundFileProviderDomains.contains(fileProviderEnabledAccountId)) {
accountIdsOfFoundFileProviderDomains.removeAll(fileProviderEnabledAccountId);
continue;
}
if (const auto accountState = AccountManager::instance()->accountFromUserId(accountUserIdAtHost)) {
if (const auto accountState = AccountManager::instance()->accountFromUserId(fileProviderEnabledAccountId)) {
qCDebug(lcMacFileProviderDomainManager) << "Succeed in fetching account state by account id"
<< accountUserIdAtHost
<< fileProviderEnabledAccountId
<< ", adding file provider domain for account.";
addFileProviderDomainForAccount(accountState.data());
} else {
qCWarning(lcMacFileProviderDomainManager) << "Could not fetch account state by account id"
<< accountUserIdAtHost
<< fileProviderEnabledAccountId
<< ", removing account from list of VFS-enabled accounts.";
FileProviderSettingsController::instance()->setVfsEnabledForAccount(accountUserIdAtHost, false);
FileProviderSettingsController::instance()->setVfsEnabledForAccount(fileProviderEnabledAccountId, false);
}
}
for (const auto &remainingDomainUserId : configuredDomains) {
const auto accountId = accountIdFromDomainId(remainingDomainUserId);
const auto accountState = AccountManager::instance()->accountFromUserId(accountId);
for (const auto &remainingAccountId : accountIdsOfFoundFileProviderDomains) {
qCDebug(lcMacFileProviderDomainManager) << "Orphaned file provider domain to remove found for account id"
<< remainingAccountId;
const auto accountState = AccountManager::instance()->accountFromUserId(remainingAccountId);
removeFileProviderDomainForAccount(accountState.data());
}
@ -721,9 +723,6 @@ void FileProviderDomainManager::removeFileProviderDomainForAccount(const Account
}
Q_ASSERT(accountState);
const auto account = accountState->account();
Q_ASSERT(account);
d->removeFileProviderDomain(accountState);
}