I copied over the rmtree function (and other functions needed by this one)

from the postgresql code so we use that instead of issuing system calls
with rm -rf ....

I also eliminated the rm -rf for pg_xlog.

Will later do the same with the other system call to remove files
in pg_replslot/
This commit is contained in:
Martin
2016-05-11 19:30:32 -03:00
parent 9a05999abb
commit b6b6439819
5 changed files with 228 additions and 7 deletions

View File

@@ -1332,6 +1332,8 @@ do_standby_clone(void)
char *first_wal_segment = NULL;
char *last_wal_segment = NULL;
char xlog_dir[MAXLEN] = "";
PQExpBufferData event_details;
@@ -1997,15 +1999,16 @@ stop_backup:
* Remove any existing WAL from the target directory, since
* rsync's --exclude option doesn't do it.
*/
maxlen_snprintf(script, "rm -rf %s/pg_xlog/*",
local_data_directory);
r = system(script);
if (r != 0)
maxlen_snprintf(xlog_dir, "%s/pg_xlog/", local_data_directory);
if (!rmtree(xlog_dir, false))
{
log_err(_("unable to empty local WAL directory %s/pg_xlog/\n"),
local_data_directory);
log_err(_("unable to empty local WAL directory %s\n"),
xlog_dir);
exit(ERR_BAD_RSYNC);
}
}
/*