From 90ad02ead6a5419ad7e708955e74ae90dc0f5cb7 Mon Sep 17 00:00:00 2001 From: "changying.yue" Date: Mon, 24 Apr 2023 08:21:37 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20NasWrite=20=E4=B8=AD?= =?UTF-8?q?=E9=87=8A=E6=94=BE=E5=86=85=E5=AD=98=E5=90=8E=E8=BF=98=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/storage/access/archive/nas_am.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gausskernel/storage/access/archive/nas_am.cpp b/src/gausskernel/storage/access/archive/nas_am.cpp index 6466459b68..522ff48a32 100644 --- a/src/gausskernel/storage/access/archive/nas_am.cpp +++ b/src/gausskernel/storage/access/archive/nas_am.cpp @@ -168,41 +168,37 @@ int NasWrite(const char* fileName, const char *buffer, const int bufferLength, A base_path = dirname(origin_file_path); if (!isDirExist(base_path)) { if (pg_mkdir_p(base_path, S_IRWXU) != 0) { - pfree_ext(origin_file_path); ereport(LOG, (errmsg("could not create path \"%s\"", base_path))); + pfree_ext(origin_file_path); return -1; } } + pfree_ext(origin_file_path); ret = snprintf_s(file_path_bak, MAXPGPATH, MAXPGPATH - 1, "%s.bak", file_path); securec_check_ss(ret, "\0", "\0"); fp = fopen(file_path_bak, "wb"); if (fp == NULL) { - pfree_ext(origin_file_path); ereport(LOG, (errmsg("could not create file \"%s\": %m", fileName))); return -1; } if (fwrite(buffer, bufferLength, 1, fp) != 1) { ereport(LOG, (errmsg("could not write file \"%s\": %m", fileName))); - pfree_ext(origin_file_path); fclose(fp); return -1; } if (fflush(fp) != 0) { ereport(LOG, (errmsg("could not fflush file \"%s\": %m", fileName))); (void)fclose(fp); - pfree_ext(origin_file_path); return -1; } if (rename(file_path_bak, file_path) < 0) { ereport(LOG, (errmsg("could not rename file \"%s\": %m", fileName))); (void)fclose(fp); - pfree_ext(origin_file_path); return -1; } - pfree_ext(origin_file_path); fclose(fp); return 0; } -- Gitee