Skip to content

Commit b352e44

Browse files
committed
fix(quota): keep error context for user and add tests.
When a local file is blocked from uploading due to remote quota (HTTP 507) and the parent folder is subsequently deleted on the server, checkErrorBlacklisting() in would overwrite the deliberate CSYNC_INSTRUCTION_ERROR set by checkNewDeleteConflict() with a generic CSYNC_INSTRUCTION_IGNORE so the user would loose the error message with the reason for the permanence of some files. Also add tests: - confirms non-quota new files are still deleted when the parent folder is removed on the server. - verifies that once the user remove the protected file locally, the next sync cleans up the now empty server-deleted folder. - same as above for a nested. Signed-off-by: Camila Ayres <hello@camilasan.com>
1 parent dd8137b commit b352e44

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/libsync/discovery.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,6 +2218,13 @@ int ProcessDirectoryJob::processSubJobs(int nbJobs)
22182218
// Do not remove a directory that has ignored files
22192219
qCInfo(lcDisco) << "Child ignored for a folder to remove" << _dirItem->_file << "direction" << _dirItem->_direction;
22202220
_dirItem->_instruction = CSYNC_INSTRUCTION_NONE;
2221+
// Invalidate the parent directory's etag so the next sync re-queries it from
2222+
// the server instead of using a ParentNotChanged cache hit. Without this, a
2223+
// parent whose etag has not changed since the server-side deletion uses its DB
2224+
// record as a proxy for server state and keeps issuing NONE for this folder.
2225+
const auto slashPos = _dirItem->_file.lastIndexOf(QLatin1Char('/'));
2226+
const auto parentPath = slashPos >= 0 ? _dirItem->_file.left(slashPos) : QString();
2227+
_discoveryData->_statedb->schedulePathForRemoteDiscovery(parentPath.toUtf8());
22212228
}
22222229
}
22232230
emit finished();

src/libsync/syncengine.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ bool SyncEngine::checkErrorBlacklisting(SyncFileItem &item)
143143

144144
item._hasBlacklistEntry = true;
145145

146+
// Discovery already produced a deliberate error for items protected in checkNewDeleteConflict.
147+
// Keep its instruction and message intact so the specific reason is displayed.
148+
// Still show the quota notification if applicable.
149+
if (item._instruction == CSYNC_INSTRUCTION_ERROR) {
150+
if (entry._errorCategory == SyncJournalErrorBlacklistRecord::InsufficientRemoteStorage) {
151+
slotInsufficientRemoteStorage();
152+
}
153+
return true;
154+
}
155+
146156
// If duration has expired, it's not blacklisted anymore
147157
time_t now = Utility::qDateTimeToTime_t(QDateTime::currentDateTimeUtc());
148158
if (now >= entry._lastTryTime + entry._ignoreDuration) {

test/testsyncdelete.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,9 @@ private slots:
104104
{
105105
auto item = completeSpy.findItem(QStringLiteral("A/quota_blocked.txt"));
106106
QVERIFY(item);
107-
const bool isErrorItem = item->_instruction == CSYNC_INSTRUCTION_ERROR
108-
|| item->_instruction == CSYNC_INSTRUCTION_IGNORE; // BlacklistedError reuses IGNORE
109-
QVERIFY(isErrorItem);
110-
const bool isErrorStatus = item->_status == SyncFileItem::SoftError
111-
|| item->_status == SyncFileItem::BlacklistedError;
112-
QVERIFY(isErrorStatus);
107+
QCOMPARE(item->_instruction, CSYNC_INSTRUCTION_ERROR);
108+
QVERIFY(item->_status == SyncFileItem::SoftError || item->_status == SyncFileItem::NormalError);
109+
QVERIFY(!item->_errorString.contains(QStringLiteral("skipped due to earlier error")));
113110
}
114111
}
115112

0 commit comments

Comments
 (0)