Skip to content

Commit 4fe1a6d

Browse files
committed
test(quota): cover discovery-time quota block protected from later deletion
Seeds the InsufficientRemoteStorage entry via the discovery quota check (no 507, no upload attempt), then verifies a later server side deletion of the parent folder still protects the file via that entry. Assisted-by: Claude Code:claude-opus-4-8 Signed-off-by: Camila Ayres <hello@camilasan.com>
1 parent bdb97ad commit 4fe1a6d

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

test/testsyncdelete.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,41 @@ private slots:
243243
QVERIFY(hadStorageNotification);
244244
}
245245

246+
// Discovery determines the file exceeds the folder quota (no 507, no upload attempt),
247+
// which seeds the InsufficientRemoteStorage entry. A later server side deletion of the
248+
// parent must then protect the file via that entry.
249+
void testQuotaBlockedDuringDiscoveryProtectedFromLaterDeletion()
250+
{
251+
FileInfo initialState{QString{}, {
252+
{QStringLiteral("A"), {
253+
{QStringLiteral("small.txt"), 4},
254+
}},
255+
}};
256+
// Skip the automatic initial sync so the quota is set before the first sync,
257+
// ensuring the DB stores bytesAvailable=50 for folder A.
258+
FakeFolder fakeFolder{initialState, {}, {}, false};
259+
fakeFolder.remoteModifier().setFolderQuota(QStringLiteral("A"), FileInfo::FolderQuota{0, 50});
260+
QVERIFY(fakeFolder.syncOnce());
261+
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
262+
263+
// Too big for the 50 byte quota: blocked during discovery, never uploaded, no 507.
264+
fakeFolder.localModifier().insert(QStringLiteral("A/big.txt"), 100);
265+
QVERIFY(!fakeFolder.syncOnce());
266+
{
267+
const auto entry = fakeFolder.syncJournal().errorBlacklistEntry(QStringLiteral("A/big.txt"));
268+
QVERIFY(entry.isValid());
269+
QCOMPARE(entry._errorCategory, SyncJournalErrorBlacklistRecord::InsufficientRemoteStorage);
270+
}
271+
QVERIFY(!fakeFolder.currentRemoteState().find(QStringLiteral("A/big.txt")));
272+
273+
// Server deletes A on a later sync: the discovery seeded entry must protect big.txt.
274+
fakeFolder.remoteModifier().remove(QStringLiteral("A"));
275+
fakeFolder.syncOnce();
276+
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("A/big.txt")));
277+
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("A")));
278+
QVERIFY(!fakeFolder.currentLocalState().find(QStringLiteral("A/small.txt")));
279+
}
280+
246281
// Files blocked from upload because of quota errors must follow their parent folder through
247282
// multiple successive server side renames.
248283
void testQuotaBlockedFileFollowsParentFolderMove()

0 commit comments

Comments
 (0)