Skip to content

Commit ddfa202

Browse files
Relloclaucambra
authored andcommitted
fix: add tests checking disconnected accounts' file provider extensions do not trigger polling ETag check
Assisted-by: GPT-5.6 Signed-off-by: Rello <github@scherello.de>
1 parent ae44818 commit ddfa202

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

src/gui/folderman.cpp

Lines changed: 8 additions & 1 deletion
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,7 +1146,7 @@ void FolderMan::slotEtagPollTimerTimeout()
11391146
for (const auto &accountState : accounts) {
11401147
const auto account = accountState->account();
11411148

1142-
if (!accountState->isConnected()) {
1149+
if (!canPollFileProviderEtag(*accountState)) {
11431150
qCDebug(lcFolderMan) << "Account" << account->displayName() << "is not connected, skipping File Provider ETag check.";
11441151
continue;
11451152
}

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)