Skip to content

Commit

Permalink
Discovery: Distinguish 503 Storage not available. #2884
Browse files Browse the repository at this point in the history
  • Loading branch information
ckamm committed Feb 25, 2015
1 parent 6f71bd9 commit 76ac628
Showing 6 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions csync/src/csync.h
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@ enum csync_status_codes_e {
CSYNC_STATUS_OUT_OF_SPACE,
CSYNC_STATUS_QUOTA_EXCEEDED, /* UNUSED */
CSYNC_STATUS_SERVICE_UNAVAILABLE,
CSYNC_STATUS_STORAGE_UNAVAILABLE,
CSYNC_STATUS_FILE_SIZE_ERROR,
CSYNC_STATUS_CONTEXT_LOST,
CSYNC_STATUS_MERGE_FILETREE_ERROR,
1 change: 1 addition & 0 deletions csync/src/csync_macros.h
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@
#define ERRNO_ERROR_STRING CSYNC_CUSTOM_ERRNO_BASE+13
#define ERRNO_SERVICE_UNAVAILABLE CSYNC_CUSTOM_ERRNO_BASE+14
#define ERRNO_USER_ABORT CSYNC_CUSTOM_ERRNO_BASE+16
#define ERRNO_STORAGE_UNAVAILABLE CSYNC_CUSTOM_ERRNO_BASE+17

#endif /* _CSYNC_MACROS_H */
/* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
3 changes: 3 additions & 0 deletions csync/src/csync_misc.c
Original file line number Diff line number Diff line change
@@ -108,6 +108,9 @@ CSYNC_STATUS csync_errno_to_status(int error, CSYNC_STATUS default_status)
case ERRNO_SERVICE_UNAVAILABLE:
status = CSYNC_STATUS_SERVICE_UNAVAILABLE; /* Service temporarily down */
break;
case ERRNO_STORAGE_UNAVAILABLE:
status = CSYNC_STATUS_STORAGE_UNAVAILABLE; /* Storage temporarily unavailable */
break;
case EFBIG:
status = CSYNC_STATUS_FILE_SIZE_ERROR; /* File larger than 2MB */
break;
6 changes: 3 additions & 3 deletions csync/src/csync_update.c
Original file line number Diff line number Diff line change
@@ -619,11 +619,11 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
if (asp < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "asprintf failed!");
}
} else if(errno == ERRNO_SERVICE_UNAVAILABLE) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Service was not available!");
} else if(errno == ERRNO_STORAGE_UNAVAILABLE) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Storage was not available!");
if (ctx->current_fs) {
ctx->current_fs->instruction = CSYNC_INSTRUCTION_IGNORE;
ctx->current_fs->error_status = CSYNC_STATUS_SERVICE_UNAVAILABLE;
ctx->current_fs->error_status = CSYNC_STATUS_STORAGE_UNAVAILABLE;
/* If a directory has ignored files, put the flag on the parent directory as well */
if( previous_fs ) {
previous_fs->has_ignored_files = true;
12 changes: 8 additions & 4 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ void DiscoveryJob::update_job_update_callback (bool local,
}


int get_errno_from_http_errcode( int err ) {
int get_errno_from_http_errcode( int err, const QString & reason ) {
int new_errno = 0;

switch(err) {
@@ -143,8 +143,11 @@ int get_errno_from_http_errcode( int err ) {
new_errno = EIO;
break;
case 503: /* Service Unavailable */
new_errno = ERRNO_SERVICE_UNAVAILABLE;
// FIXME Distinguish between service unavailable and storage unavilable
if (reason == "Storage not available") {
new_errno = ERRNO_STORAGE_UNAVAILABLE;
} else {
new_errno = ERRNO_SERVICE_UNAVAILABLE;
}
break;
case 413: /* Request Entity too Large */
new_errno = EFBIG;
@@ -276,11 +279,12 @@ void DiscoverySingleDirectoryJob::lsJobFinishedWithErrorSlot(QNetworkReply *r)
{
QString contentType = r->header(QNetworkRequest::ContentTypeHeader).toString();
int httpCode = r->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
QString httpReason = r->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
QString msg = r->errorString();
int errnoCode = 0;
qDebug() << Q_FUNC_INFO << r->errorString() << httpCode << r->error();
if (httpCode != 0 && httpCode != 207) {
errnoCode = get_errno_from_http_errcode(httpCode);
errnoCode = get_errno_from_http_errcode(httpCode, httpReason);
} else if (r->error() != QNetworkReply::NoError) {
errnoCode = EIO;
} else if (!contentType.contains("application/xml; charset=utf-8")) {
6 changes: 6 additions & 0 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
@@ -153,6 +153,9 @@ QString SyncEngine::csyncErrorToString(CSYNC_STATUS err)
errStr = tr("Aborted by the user");
break;
case CSYNC_STATUS_SERVICE_UNAVAILABLE:
errStr = tr("The service is temporarily unavailable");
break;
case CSYNC_STATUS_STORAGE_UNAVAILABLE:
errStr = tr("The mounted directory is temporarily not available on the server");
break;
case CSYNC_STATUS_OPENDIR_ERROR:
@@ -369,6 +372,9 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
item._errorString = QLatin1String("File locked"); // don't translate, internal use!
break;
case CSYNC_STATUS_SERVICE_UNAVAILABLE:
item._errorString = QLatin1String("Server temporarily unavailable.");
break;
case CSYNC_STATUS_STORAGE_UNAVAILABLE:
item._errorString = QLatin1String("Directory temporarily not available on server.");
item._status = SyncFileItem::SoftError;
break;

0 comments on commit 76ac628

Please sign in to comment.