Use rmtree instead of executing "rm -rf"

This completes the task mentioned in b6b6439819
This commit is contained in:
Ian Barwick
2016-07-06 15:55:56 +09:00
parent 5e03ef40cb
commit 72f9b0145a

View File

@@ -768,9 +768,9 @@ do_cluster_show(void)
conn = establish_db_connection(options.conninfo, true); conn = establish_db_connection(options.conninfo, true);
sqlquery_snprintf(sqlquery, sqlquery_snprintf(sqlquery,
"SELECT conninfo, type, name, upstream_node_name, id" "SELECT conninfo, type, name, upstream_node_name, id"
" FROM %s.repl_show_nodes", " FROM %s.repl_show_nodes",
get_repmgr_schema_quoted(conn)); get_repmgr_schema_quoted(conn));
log_verbose(LOG_DEBUG, "do_cluster_show(): \n%s\n",sqlquery ); log_verbose(LOG_DEBUG, "do_cluster_show(): \n%s\n",sqlquery );
@@ -1371,8 +1371,6 @@ do_standby_clone(void)
char *first_wal_segment = NULL; char *first_wal_segment = NULL;
char *last_wal_segment = NULL; char *last_wal_segment = NULL;
char xlog_dir[MAXLEN] = "";
PQExpBufferData event_details; PQExpBufferData event_details;
@@ -2043,8 +2041,8 @@ stop_backup:
*/ */
if (runtime_options.rsync_only) if (runtime_options.rsync_only)
{ {
char script[MAXLEN];
char label_path[MAXPGPATH]; char label_path[MAXPGPATH];
char dirpath[MAXLEN] = "";
if (runtime_options.force) if (runtime_options.force)
{ {
@@ -2053,15 +2051,14 @@ stop_backup:
* rsync's --exclude option doesn't do it. * rsync's --exclude option doesn't do it.
*/ */
maxlen_snprintf(xlog_dir, "%s/pg_xlog/", local_data_directory); maxlen_snprintf(dirpath, "%s/pg_xlog/", local_data_directory);
if (!rmtree(xlog_dir, false)) if (!rmtree(dirpath, false))
{ {
log_err(_("unable to empty local WAL directory %s\n"), log_err(_("unable to empty local WAL directory %s\n"),
xlog_dir); dirpath);
exit(ERR_BAD_RSYNC); exit(ERR_BAD_RSYNC);
} }
} }
/* /*
@@ -2082,15 +2079,15 @@ stop_backup:
if (server_version_num >= 90400 && if (server_version_num >= 90400 &&
backup_label.min_failover_slot_lsn == InvalidXLogRecPtr) backup_label.min_failover_slot_lsn == InvalidXLogRecPtr)
{ {
maxlen_snprintf(script, "rm -rf %s/pg_replslot/*", maxlen_snprintf(dirpath, "%s/pg_replslot/*",
local_data_directory); local_data_directory);
log_debug("deleting pg_replslot directory contents\n"); log_debug("deleting pg_replslot directory contents\n");
r = system(script);
if (r != 0) if (!rmtree(dirpath, false))
{ {
log_err(_("unable to empty replication slot directory %s/pg_replslot/\n"), log_err(_("unable to empty replication slot directory %s\n"),
local_data_directory); dirpath);
exit(ERR_BAD_RSYNC); exit(ERR_BAD_RSYNC);
} }
} }