Skip to content

Commit d9d2bd4

Browse files
authored
Merge pull request #10445 from nextcloud/bugfix/fileProviderAuthCheck
fix(file-provider): Do not continue polling ETag from file provider when account is disabled
2 parents 4c605fe + ddfa202 commit d9d2bd4

3 files changed

Lines changed: 41 additions & 0 deletions

File tree

src/gui/folderman.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,13 @@ bool FolderMan::isSwitchToVfsNeeded(const FolderDefinition &folderDefinition) co
11091109
return result;
11101110
}
11111111

1112+
#ifdef BUILD_FILE_PROVIDER_MODULE
1113+
bool FolderMan::canPollFileProviderEtag(const AccountState &accountState)
1114+
{
1115+
return accountState.isConnected();
1116+
}
1117+
#endif
1118+
11121119
void FolderMan::slotEtagPollTimerTimeout()
11131120
{
11141121
qCInfo(lcFolderMan) << "Etag poll timer timeout";
@@ -1139,6 +1146,11 @@ void FolderMan::slotEtagPollTimerTimeout()
11391146
for (const auto &accountState : accounts) {
11401147
const auto account = accountState->account();
11411148

1149+
if (!canPollFileProviderEtag(*accountState)) {
1150+
qCDebug(lcFolderMan) << "Account" << account->displayName() << "is not connected, skipping File Provider ETag check.";
1151+
continue;
1152+
}
1153+
11421154
// Skip accounts that don't have a File Provider domain
11431155
if (!Mac::FileProvider::instance()->domainManager()->domainForAccount(account.data())) {
11441156
qCDebug(lcFolderMan) << "Account" << account->displayName() << "has no file provider domain, skipping.";

src/gui/folderman.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ private slots:
357357
void runEtagJobsIfPossible(const QList<Folder *> &folderMap);
358358
void runEtagJobIfPossible(Folder *folder);
359359

360+
#ifdef BUILD_FILE_PROVIDER_MODULE
361+
/** @brief Returns whether the account state permits File Provider ETag polling. */
362+
[[nodiscard]] static bool canPollFileProviderEtag(const AccountState &accountState);
363+
#endif
364+
360365
bool pushNotificationsFilesReady(const OCC::AccountPtr &account);
361366

362367
[[nodiscard]] bool isSwitchToVfsNeeded(const FolderDefinition &folderDefinition) const;

test/testfolderman.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,30 @@ private slots:
609609
}
610610

611611
#ifdef BUILD_FILE_PROVIDER_MODULE
612+
void testFileProviderEtagPollingRequiresConnectedAccount()
613+
{
614+
const auto accountState = std::make_unique<FakeAccountState>(Account::create());
615+
QVERIFY(FolderMan::canPollFileProviderEtag(*accountState));
616+
617+
const auto disconnectedStates = {
618+
AccountState::SignedOut,
619+
AccountState::Disconnected,
620+
AccountState::ServiceUnavailable,
621+
AccountState::RedirectDetected,
622+
AccountState::MaintenanceMode,
623+
AccountState::NetworkError,
624+
AccountState::ConfigurationError,
625+
AccountState::AskingCredentials,
626+
AccountState::NeedToSignTermsOfService,
627+
};
628+
629+
for (const auto state : disconnectedStates) {
630+
accountState->setStateForTesting(state);
631+
QVERIFY2(!FolderMan::canPollFileProviderEtag(*accountState),
632+
qPrintable(AccountState::stateString(state)));
633+
}
634+
}
635+
612636
void testAddFolderRefusedWhenFileProviderModeEnabled()
613637
{
614638
_fm.reset({});

0 commit comments

Comments
 (0)