diff --git a/cartridge/clusterwide-config.c b/cartridge/clusterwide-config.c index 1a442ca67..eccafecea 100644 --- a/cartridge/clusterwide-config.c +++ b/cartridge/clusterwide-config.c @@ -76,24 +76,17 @@ static int cw_save(char* path, char* random_path, char** sections_k, char** sect if(file_write(tmp_path, sections_v[i]) == -1) { say_error("file_write() error: %s", strerror(errno)); sprintf(err, "%s: %s", tmp_path, strerror(errno)); - goto rollback; + return -1; } } if(rename(random_path, path) == -1) { say_error("rename() error: %s", strerror(errno)); sprintf(err, "%s: %s", path, strerror(errno)); - goto rollback; + return -1; } say_verbose("%s has renamed to %s", random_path, path); - goto exit; -rollback: - if(remove(random_path) == -1) { - say_warn("remove error: %s, path: %s", strerror(errno), random_path); - } - return -1; -exit: return 0; } diff --git a/cartridge/clusterwide-config.lua b/cartridge/clusterwide-config.lua index cf9d37b38..d413b660f 100644 --- a/cartridge/clusterwide-config.lua +++ b/cartridge/clusterwide-config.lua @@ -494,6 +494,13 @@ local function save(clusterwide_config, path) end local ok, err = internal.save(path, random_path, sections_k, sections_v) if not ok and err then + local _, rm_err = fio.rmtree(random_path) + if rm_err then + log.warn( + "Error removing %s: %s", + random_path, err + ) + end return nil, SaveConfigError:new("%s: %s", path, err) end return true