Open realflash opened 1 week ago
Hacky workaround:
use File::Path qw/ rmtree /;
use File::Basename;
post '/ingest' => sub {
my $file = request->upload('uploaded_file');
$log->debug("Uploaded file saved to ".$file->tempname);
# Do all the things you need to do with the file first
# Make sure file is actually deleted
my ($name, $path, $suffix) = fileparse($file->tempname);
if($^O =~ /^MSWin/)
{
my $result = `rmdir /s /q "$path" 2>&1`;
die "Error deleting file $path: $result" if length($result) > 0;
}
else
{
rmtree($path);
}
return template 'uploaded';
Dancer (or whatever underlying library is used) seems not to object to the fact that the file is not there when DESTROY is called so there is no follow in error from doing this.
@realflash thanks for the report! This will require some investigation.
Current CPAN version of Dancer2 1.1.0 Running under Strawberry Perl (64-bit) Portable 5.38.2.2-64bit on Windows 11
Here's the handler:
Here's the result:
The file is not deleted, and I assume it is meant to be though that is not clear from the POD for this class.