Storage now prunes empty directories when delete is called.

Add use WebGUI::Form::Hidden to Form::File
This commit is contained in:
Colin Kuskie 2006-05-19 21:48:10 +00:00
parent e136fb5b4e
commit f413c029a2
4 changed files with 26 additions and 2 deletions

View file

@ -18,6 +18,7 @@ use strict;
use base 'WebGUI::Form::Control';
use WebGUI::International;
use WebGUI::Storage;
use WebGUI::Form::Hidden;
=head1 NAME

View file

@ -376,7 +376,19 @@ Deletes this storage location and its contents (if any) from the filesystem.
sub delete {
my $self = shift;
my $path = $self->getPath;
rmtree($path) if ($path);
if ($path) {
rmtree($path) if ($path);
foreach my $subDir ($self->{_part1}.'/'.$self->{_part2}, $self->{_part1}) {
my $uDir = $self->session->config->get('uploadsPath') . '/' . $subDir;
opendir my $DH, $uDir or
$self->session->errorHandler->fatal("Unable to open $uDir for directory reading");
my @dirs = grep { !/^\.+$/ } readdir($DH);
if (scalar @dirs == 0) {
rmtree($uDir);
}
close $DH;
}
}
return;
}