- my $ok = 1;
- foreach my $suffix (qw(tmp git)) {
- my $dir = "${subdir}\\.$suffix";
- my $errs;
- remove_tree($dir, { safe=>1, error=>\$errs });
- if (stat $dir) {
- $ok = 0;
- logm 'warning', "housekeeping: $dir: problems with".
- "deletion prevent cleanup:";
- foreach my $err (@$errs) {
- logm 'info', "problem deleting: $err->[0]: $err->[1]";
+ eval {
+ foreach my $suffix (qw(tmp git)) {
+ my $dir = "${subdir}\\.$suffix";
+ my $tdir = "${subdir}\\.tmp";
+ if ($dir ne $tdir) {
+ if (!rename $dir,$tdir) {
+ next if $! == ENOENT;
+ die "$dir: cannot rename to $tdir: $!\n";
+ }
+ }
+ system qw(rm -rf --), $tdir;
+ if (stat $tdir) {
+ die "$dir: problem deleting file(s), rm exited $?\n";
+ } elsif ($! != ENOENT) {
+ die "$tdir: cannot stat after deletion: $!\n";