From 4cb6b0f57ca4b5907bb05aa1048d68f86ba23604 Mon Sep 17 00:00:00 2001 From: Dalton Bohning Date: Fri, 7 Oct 2022 22:38:42 +0000 Subject: [PATCH 1/2] mfu_param_path: fix cutting root component Even when `! copy_into_dir`, we still still shouldn't cut the root component. Signed-off-by: Dalton Bohning --- src/common/mfu_param_path.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/common/mfu_param_path.c b/src/common/mfu_param_path.c index 488d4f2d..fed0bc54 100644 --- a/src/common/mfu_param_path.c +++ b/src/common/mfu_param_path.c @@ -401,13 +401,12 @@ char* mfu_param_path_copy_dest(const char* name, int numpaths, * if path is root, keep last component. * otherwise cut all components listed in source path */ int cut = src_components; - if (mfu_copy_opts->copy_into_dir && cut > 0) { - if (strcmp(paths[i].orig, "/") == 0) { - cut--; - } else if ((mfu_copy_opts->do_sync != 1) && - (paths[i].orig[strlen(paths[i].orig) - 1] != '/')) { - cut--; - } + if (cut > 0 && strcmp(paths[i].orig, "/") == 0) { + cut--; + } + if ((cut > 0) && mfu_copy_opts->copy_into_dir && + (mfu_copy_opts->do_sync != 1) && (paths[i].orig[strlen(paths[i].orig) - 1] != '/')) { + cut--; } /* compute number of components to keep */ From bc68b977b5df421338860f48ef3e706259aaaa07 Mon Sep 17 00:00:00 2001 From: Dalton Bohning Date: Wed, 26 Oct 2022 16:07:57 +0000 Subject: [PATCH 2/2] else -> else if to be clear Signed-off-by: Dalton Bohning --- src/common/mfu_param_path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/mfu_param_path.c b/src/common/mfu_param_path.c index fed0bc54..44da9e64 100644 --- a/src/common/mfu_param_path.c +++ b/src/common/mfu_param_path.c @@ -404,7 +404,7 @@ char* mfu_param_path_copy_dest(const char* name, int numpaths, if (cut > 0 && strcmp(paths[i].orig, "/") == 0) { cut--; } - if ((cut > 0) && mfu_copy_opts->copy_into_dir && + else if ((cut > 0) && mfu_copy_opts->copy_into_dir && (mfu_copy_opts->do_sync != 1) && (paths[i].orig[strlen(paths[i].orig) - 1] != '/')) { cut--; }