From dd14388b1b9f16848a875e719878341237d44ceb Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 14 Jul 2013 12:25:31 -0400 Subject: [PATCH] Sync - Implemented (weak) handling for a 310 "Redirect" server response. --- src/commands/CmdSync.cpp | 10 +++++++++- src/en-US.h | 2 ++ src/es-ES.h | 3 ++- src/fr-FR.h | 2 ++ src/it-IT.h | 2 ++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/commands/CmdSync.cpp b/src/commands/CmdSync.cpp index 5166eedca..d5d94c72d 100644 --- a/src/commands/CmdSync.cpp +++ b/src/commands/CmdSync.cpp @@ -209,6 +209,7 @@ int CmdSync::execute (std::string& output) // Present a clear status message. if (upload_count == 0 && download_count == 0) + // Note: should not happen - expect code 201 instead. context.footnote (STRING_CMD_SYNC_SUCCESS0); else if (upload_count == 0 && download_count > 0) context.footnote (format (STRING_CMD_SYNC_SUCCESS2, download_count)); @@ -222,6 +223,13 @@ int CmdSync::execute (std::string& output) { context.footnote (STRING_CMD_SYNC_SUCCESS_NOP); } + else if (code == "301") + { + std::string new_server = response.get ("info"); + context.config.set ("taskd.server", new_server); + context.error (STRING_CMD_SYNC_RELOCATE0); + context.error (" " + format (STRING_CMD_SYNC_RELOCATE1, new_server)); + } else if (code == "430") { context.error (STRING_CMD_SYNC_FAIL_ACCOUNT); @@ -235,7 +243,7 @@ int CmdSync::execute (std::string& output) status = 2; } - // Display all errors returned. This is required by the server protocol. + // Display all errors returned. This is recommended by the server protocol. std::string to_be_displayed = response.get ("messages"); if (to_be_displayed != "") { diff --git a/src/en-US.h b/src/en-US.h index dbdb6ecf2..71ddd5f34 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -420,6 +420,8 @@ #define STRING_CMD_SYNC_NO_TLS "Taskwarrior was built without GnuTLS support. Sync is not available." #define STRING_CMD_SYNC_INIT "Please confirm that you wish to upload all your pending tasks to the Task Server" #define STRING_CMD_SYNC_NO_INIT "Taskwarrior will not proceed with first-time sync initialization." +#define STRING_CMD_SYNC_RELOCATE0 "The server account has been relocated. Please update your configuration using:" +#define STRING_CMD_SYNC_RELOCATE1 "task config taskd.server {1}" #define STRING_CMD_DIAG_USAGE "Platform, build and environment details" #define STRING_CMD_DIAG_PLATFORM "Platform" #define STRING_CMD_DIAG_UNKNOWN "" diff --git a/src/es-ES.h b/src/es-ES.h index a63d207d0..b0a34f08b 100644 --- a/src/es-ES.h +++ b/src/es-ES.h @@ -430,8 +430,9 @@ #define STRING_CMD_SYNC_BAD_SERVER "Sincronización fallida. Ajuste de configuración '{1}' incorrecto" #define STRING_CMD_SYNC_NO_TLS "Taskwarrior fue construido sin soporte GnuTLS. Sincronización no disponible." #define STRING_CMD_SYNC_INIT "Por favor, confirme que desea subir todas sus tareas pendientes al Servidor Task" -#define STRING_CMD_SYNC_NO_INIT "Taskwarrior will not proceed with first-time sync initialization." #define STRING_CMD_SYNC_NO_INIT "Taskwarrior will no procederá a la inicialización de la sincronización por primera vez." +#define STRING_CMD_SYNC_RELOCATE0 "The server account has been relocated. Please update your configuration using:" +#define STRING_CMD_SYNC_RELOCATE1 "task config taskd.server {1}" #define STRING_CMD_DIAG_USAGE "Detalles de plataforma, construcción y entorno" #define STRING_CMD_DIAG_PLATFORM "Plataforma" #define STRING_CMD_DIAG_UNKNOWN "" diff --git a/src/fr-FR.h b/src/fr-FR.h index eb595f07c..e895d4a7b 100644 --- a/src/fr-FR.h +++ b/src/fr-FR.h @@ -420,6 +420,8 @@ #define STRING_CMD_SYNC_NO_TLS "Taskwarrior was built without GnuTLS support. Sync is not available." #define STRING_CMD_SYNC_INIT "Please confirm that you wish to upload all your pending tasks to the Task Server" #define STRING_CMD_SYNC_NO_INIT "Taskwarrior will not proceed with first-time sync initialization." +#define STRING_CMD_SYNC_RELOCATE0 "The server account has been relocated. Please update your configuration using:" +#define STRING_CMD_SYNC_RELOCATE1 "task config taskd.server {1}" #define STRING_CMD_DIAG_USAGE "Platform, build and environment details" #define STRING_CMD_DIAG_PLATFORM "Platform" #define STRING_CMD_DIAG_UNKNOWN "" diff --git a/src/it-IT.h b/src/it-IT.h index 0cd670ac6..a51f24b2a 100644 --- a/src/it-IT.h +++ b/src/it-IT.h @@ -421,6 +421,8 @@ #define STRING_CMD_SYNC_NO_TLS "Taskwarrior was built without GnuTLS support. Sync is not available." #define STRING_CMD_SYNC_INIT "Please confirm that you wish to upload all your pending tasks to the Task Server" #define STRING_CMD_SYNC_NO_INIT "Taskwarrior will not proceed with first-time sync initialization." +#define STRING_CMD_SYNC_RELOCATE0 "The server account has been relocated. Please update your configuration using:" +#define STRING_CMD_SYNC_RELOCATE1 "task config taskd.server {1}" #define STRING_CMD_DIAG_USAGE "Dettagli su piattaforma, build e ambiente" #define STRING_CMD_DIAG_PLATFORM "Piattaforma" #define STRING_CMD_DIAG_UNKNOWN ""