From 98b5288e9b55c4ff27b77c68891b93008f68fc23 Mon Sep 17 00:00:00 2001 From: feiniks <36756310+feiniks@users.noreply.github.com> Date: Fri, 21 Jul 2023 15:06:44 +0800 Subject: [PATCH] Add block missing sync error (#2694) * Add block missing sync error * Print response body when block is missing --------- Co-authored-by: heran yang --- daemon/http-tx-mgr.c | 12 +++++++++--- daemon/seafile-error.c | 5 +++++ include/seafile-error.h | 3 ++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/daemon/http-tx-mgr.c b/daemon/http-tx-mgr.c index 9ef83a7c9..4bd8d1db1 100644 --- a/daemon/http-tx-mgr.c +++ b/daemon/http-tx-mgr.c @@ -45,6 +45,7 @@ #define HTTP_REPO_DELETED 444 #define HTTP_REPO_TOO_LARGE 447 #define HTTP_REPO_CORRUPTED 445 +#define HTTP_BLOCK_MISSING 446 #define HTTP_INTERNAL_SERVER_ERROR 500 #define RESET_BYTES_INTERVAL_MSEC 1000 @@ -3817,11 +3818,16 @@ update_branch (HttpTxTask *task, Connection *conn) seaf_warning ("Bad response code for PUT %s: %d.\n", url, status); handle_http_errors (task, status); - if (status == HTTP_FORBIDDEN) { + if (status == HTTP_FORBIDDEN || status == HTTP_BLOCK_MISSING) { rsp_content_str = g_new0 (gchar, rsp_size + 1); memcpy (rsp_content_str, rsp_content, rsp_size); - seaf_warning ("%s\n", rsp_content_str); - notify_permission_error (task, rsp_content_str); + if (status == HTTP_FORBIDDEN) { + seaf_warning ("%s\n", rsp_content_str); + notify_permission_error (task, rsp_content_str); + } else if (status == HTTP_BLOCK_MISSING) { + seaf_warning ("Failed to upload files: %s\n", rsp_content_str); + task->error = SYNC_ERROR_ID_BLOCK_MISSING; + } g_free (rsp_content_str); } diff --git a/daemon/seafile-error.c b/daemon/seafile-error.c index f333dfcf7..6b7a1d345 100644 --- a/daemon/seafile-error.c +++ b/daemon/seafile-error.c @@ -189,6 +189,11 @@ static SyncErrorInfo sync_error_info_tbl[] = { SYNC_ERROR_LEVEL_FILE, "Failed to checkout file on the client. Please check disk space or folder permissions" }, + { + SYNC_ERROR_ID_BLOCK_MISSING, + SYNC_ERROR_LEVEL_REPO, + "Failed to upload file blocks. Please check network or firewall" + }, }; const char * diff --git a/include/seafile-error.h b/include/seafile-error.h index cb15b42ee..280ea23eb 100644 --- a/include/seafile-error.h +++ b/include/seafile-error.h @@ -65,6 +65,7 @@ #define SYNC_ERROR_ID_DEL_CONFIRMATION_PENDING 33 #define SYNC_ERROR_ID_TOO_MANY_FILES 34 #define SYNC_ERROR_ID_CHECKOUT_FILE 35 -#define N_SYNC_ERROR_ID 36 +#define SYNC_ERROR_ID_BLOCK_MISSING 36 +#define N_SYNC_ERROR_ID 37 #endif