[Pkg-owncloud-commits] [owncloud-client] 56/164: Discovery: Distinguish 503 Storage not available. #2884
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sun Mar 22 11:56:52 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 76ac628153bad54d7853e03e5efaccd9a6a4b30f
Author: Christian Kamm <kamm at incasoftware.de>
Date: Wed Feb 25 08:57:39 2015 +0100
Discovery: Distinguish 503 Storage not available. #2884
---
csync/src/csync.h | 1 +
csync/src/csync_macros.h | 1 +
csync/src/csync_misc.c | 3 +++
csync/src/csync_update.c | 6 +++---
src/libsync/discoveryphase.cpp | 12 ++++++++----
src/libsync/syncengine.cpp | 6 ++++++
6 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/csync/src/csync.h b/csync/src/csync.h
index f8c58b4..5bca3c9 100644
--- a/csync/src/csync.h
+++ b/csync/src/csync.h
@@ -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,
diff --git a/csync/src/csync_macros.h b/csync/src/csync_macros.h
index af6d705..925a523 100644
--- a/csync/src/csync_macros.h
+++ b/csync/src/csync_macros.h
@@ -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: */
diff --git a/csync/src/csync_misc.c b/csync/src/csync_misc.c
index 36c5123..5a2100c 100644
--- a/csync/src/csync_misc.c
+++ b/csync/src/csync_misc.c
@@ -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;
diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c
index 2a68bb8..f966309 100644
--- a/csync/src/csync_update.c
+++ b/csync/src/csync_update.c
@@ -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;
diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp
index 1916ba8..3f34596 100644
--- a/src/libsync/discoveryphase.cpp
+++ b/src/libsync/discoveryphase.cpp
@@ -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")) {
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index accf44e..35ebca2 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -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;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list