aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_upgrade/util.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c
index 42dcbfc5b5c..21ba4c8f12b 100644
--- a/src/bin/pg_upgrade/util.c
+++ b/src/bin/pg_upgrade/util.c
@@ -68,7 +68,12 @@ cleanup_output_dirs(void)
if (log_opts.retain)
return;
- (void) rmtree(log_opts.basedir, true);
+ /*
+ * Try twice. The second time might wait for files to finish being
+ * unlinked, on Windows.
+ */
+ if (!rmtree(log_opts.basedir, true))
+ rmtree(log_opts.basedir, true);
/* Remove pg_upgrade_output.d only if empty */
switch (pg_check_dir(log_opts.rootdir))
@@ -80,7 +85,13 @@ cleanup_output_dirs(void)
case 1: /* exists and empty */
case 2: /* exists and contains only dot files */
- (void) rmtree(log_opts.rootdir, true);
+
+ /*
+ * Try twice. The second time might wait for files to finish
+ * being unlinked, on Windows.
+ */
+ if (!rmtree(log_opts.rootdir, true))
+ rmtree(log_opts.rootdir, true);
break;
case 4: /* exists */