Skip to content

Commit 73ca037

Browse files
committed
refactor(quota): replace _httpErrorCode 507 with _isQuotaError bool flag.
Instead of faking an HTTP 507 response code on items that exceeded quota during discovery, rename the unused _errorMayBeBlacklisted field to _isQuotaError and set it at the three discovery call sites. blacklistUpdate already checked that flag for the mayBlacklist gate; createBlacklistEntry now checks it alongside the real HTTP 507 path to write the InsufficientRemoteStorage category. Signed-off-by: Camila Ayres <hello@camilasan.com>
1 parent fa7f0b5 commit 73ca037

3 files changed

Lines changed: 14 additions & 17 deletions

File tree

src/libsync/discovery.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,11 +1250,10 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
12501250
}
12511251

12521252
item->_status = SyncFileItem::Status::NormalError;
1253-
// Mark as a quota error so blacklistUpdate writes an InsufficientRemoteStorage entry.
1254-
// Without this, _httpErrorCode would be 0 and blacklistUpdate would not create an
1255-
// entry, leaving the file unprotected by checkNewDeleteConflict if the remote parent
1256-
// folder is deleted before the quota situation is resolved.
1257-
item->_httpErrorCode = 507;
1253+
// Flag as a quota error so blacklistUpdate writes an InsufficientRemoteStorage entry,
1254+
// which checkNewDeleteConflict uses to protect the file if its parent folder is later
1255+
// deleted on the server before the quota situation is resolved.
1256+
item->_isQuotaError = true;
12581257
_discoveryData->_anotherSyncNeeded = true;
12591258
_discoveryData->_filesNeedingScheduledSync.insert(path._original, delayIntervalForSyncRetryForFilesExceedQuotaSeconds);
12601259
}
@@ -2557,9 +2556,7 @@ bool ProcessDirectoryJob::checkNewDeleteConflict(const SyncFileItemPtr &item, in
25572556
<< item->_file;
25582557
item->_instruction = CSYNC_INSTRUCTION_ERROR;
25592558
item->_status = SyncFileItem::SoftError;
2560-
// Keep _httpErrorCode at 507 so blacklistUpdate recreates the InsufficientRemoteStorage
2561-
// entry if the ignore duration later expires.
2562-
item->_httpErrorCode = 507;
2559+
item->_isQuotaError = true;
25632560
item->_errorString = tr("%1 could not be removed: it has unsynced changes due to full server storage. "
25642561
"Please manage your files and try syncing again.")
25652562
.arg(item->_file);
@@ -2582,7 +2579,7 @@ bool ProcessDirectoryJob::checkNewDeleteConflict(const SyncFileItemPtr &item, in
25822579
<< item->_file;
25832580
item->_instruction = CSYNC_INSTRUCTION_ERROR;
25842581
item->_status = SyncFileItem::SoftError;
2585-
item->_httpErrorCode = 507;
2582+
item->_isQuotaError = true;
25862583
item->_errorString = tr("\"%1\" was not deleted because its latest changes were not synced "
25872584
"and your server quota was exceeded. "
25882585
"Please manage your storage and try syncing again.")

src/libsync/owncloudpropagator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static SyncJournalErrorBlacklistRecord createBlacklistEntry(
158158
entry._ignoreDuration = 0;
159159
}
160160

161-
if (item._httpErrorCode == 507) {
161+
if (item._isQuotaError || item._httpErrorCode == 507) {
162162
entry._errorCategory = SyncJournalErrorBlacklistRecord::InsufficientRemoteStorage;
163163
// Quota can change at any time (user frees space, admin adjusts limits).
164164
// Always retry on the next sync rather than backing off exponentially.
@@ -177,11 +177,11 @@ void blacklistUpdate(SyncJournalDb *journal, SyncFileItem &item)
177177
SyncJournalErrorBlacklistRecord oldEntry = journal->errorBlacklistEntry(item._file);
178178

179179
bool mayBlacklist =
180-
item._errorMayBeBlacklisted // explicitly flagged for blacklisting
180+
item._isQuotaError // quota errors always get an InsufficientRemoteStorage entry
181181
|| ((item._status == SyncFileItem::NormalError
182182
|| item._status == SyncFileItem::SoftError
183183
|| item._status == SyncFileItem::DetailError)
184-
&& item._httpErrorCode != 0 // or non-local error
184+
&& item._httpErrorCode != 0 // non-local error
185185
);
186186

187187
// No new entry? Possibly remove the old one, then done.

src/libsync/syncfileitem.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class OWNCLOUDSYNC_EXPORT SyncFileItem
130130
, _direction(None)
131131
, _serverHasIgnoredFiles(false)
132132
, _hasBlacklistEntry(false)
133-
, _errorMayBeBlacklisted(false)
133+
, _isQuotaError(false)
134134
, _status(NoStatus)
135135
, _isRestoration(false)
136136
, _isSelectiveSync(false)
@@ -261,12 +261,12 @@ class OWNCLOUDSYNC_EXPORT SyncFileItem
261261
/// without the status being FileIgnored.
262262
bool _hasBlacklistEntry BITFIELD(1);
263263

264-
/** If true and NormalError, this error may be blacklisted
264+
/** True when discovery detected that this item exceeds the remote storage quota.
265265
*
266-
* Note that non-local errors (httpErrorCode!=0) may also be
267-
* blacklisted independently of this flag.
266+
* Causes blacklistUpdate to write an InsufficientRemoteStorage entry even
267+
* though no HTTP request was made (and _httpErrorCode is therefore 0).
268268
*/
269-
bool _errorMayBeBlacklisted BITFIELD(1);
269+
bool _isQuotaError BITFIELD(1);
270270

271271
// Variables useful to report to the user
272272
Status _status BITFIELD(4);

0 commit comments

Comments
 (0)