From 166645aa3bed6bdd01ea611544dcebe5019f81e3 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Thu, 5 Jan 2017 14:29:02 -0800 Subject: [PATCH] Improve pack download error handling Make sure tar extraction errors count towards pack errors, and use the generic ENOSWUPDSERVER if download retries do not resolve the issue. Signed-off-by: Patrick McCarty --- src/packs.c | 7 ++++++- src/update.c | 1 + src/verify.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/packs.c b/src/packs.c index 9158a62d..0f7d0341 100644 --- a/src/packs.c +++ b/src/packs.c @@ -85,7 +85,12 @@ static int download_pack(int oldversion, int newversion, char *module) fclose(tarfile); } - return err; + // Only negative return values should indicate errors + if (err > 0) { + return -err; + } else { + return err; + } } /* pull in packs for base and any subscription */ diff --git a/src/update.c b/src/update.c index cc22242e..fc2766e4 100644 --- a/src/update.c +++ b/src/update.c @@ -368,6 +368,7 @@ download_packs: goto download_packs; } printf("No network, or server unavailable for pack downloads\n"); + ret = ENOSWUPDSERVER; goto clean_exit; } diff --git a/src/verify.c b/src/verify.c index 4fc81baa..522da9a2 100644 --- a/src/verify.c +++ b/src/verify.c @@ -231,7 +231,7 @@ static int get_all_files(struct manifest *official_manifest, struct list *subs) * logging needed */ printf("zero pack downloads failed. \n"); printf("Failed - Server-side error, cannot download necessary files\n"); - return ret; + return -ENOSWUPDSERVER; } iter = list_head(official_manifest->files); while (iter) {