Skip to content

Commit

Permalink
Switch rmtree to Mojo::File::remove_tree
Browse files Browse the repository at this point in the history
  • Loading branch information
pstaabp committed Oct 16, 2023
1 parent 07b21d4 commit 46242bc
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/WeBWorK/ContentGenerator/Hardcopy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ problem sets.
use File::Path;
use File::Copy qw(move copy);
use File::Temp qw/tempdir/;
use Mojo::File;
use String::ShellQuote;
use Archive::Zip::SimpleZip qw($SimpleZipError);
use XML::LibXML;
Expand Down Expand Up @@ -628,14 +629,11 @@ async sub generate_hardcopy ($c, $format, $userIDsRef, $setIDsRef) {

# helper function to remove temp dirs
sub delete_temp_dir ($c, $temp_dir_path) {
rmtree($temp_dir_path), { error => \my $err };
Mojo::File->new($temp_dir_path)->remove_tree;

if ($err && @$err) {
for my $diag (@$err) {
my ($file, $message) = %$diag;
$c->add_error('Failed to remove temporary directory "',
$c->tag('code', $file, '":', $c->tag('br'), $c->tag('pre', $message)));
}
if ($!) {
$c->add_error('Failed to remove temporary directory "',
$c->tag('code', $file, '":', $c->tag('br'), $c->tag('pre', $!)));
}
return;
}
Expand Down

0 comments on commit 46242bc

Please sign in to comment.