fixing test warnings, Storage should always return to the correct directory

This commit is contained in:
Graham Knop 2008-02-29 07:00:29 +00:00
parent f1ca6d93f8
commit 8533cf8ae8
3 changed files with 26 additions and 21 deletions

View file

@ -458,11 +458,10 @@ sub delete {
my $path = $self->getPath;
if ($path) {
rmtree($path) if ($path);
rmtree($path) if (-d $path);
foreach my $subDir ($self->{_part1}.'/'.$self->{_part2}, $self->{_part1}) {
my $uDir = $self->session->config->get('uploadsPath') . '/' . $subDir;
opendir my ($DH), $uDir;
if (defined $DH) {
if (opendir my $DH, $uDir) {
my @dirs = grep { !/^\.+$/ } readdir($DH);
if (scalar @dirs == 0) {
rmtree($uDir);
@ -661,14 +660,16 @@ The name of the file to get the icon for.
=cut
sub getFileIconUrl {
my $self = shift;
my $filename = shift;
my $extension = $self->getFileExtension($filename);
my $path = $self->session->config->get("extrasPath").'/fileIcons/'.$extension.".gif";
if (-e $path && $extension) {
return $self->session->url->extras("fileIcons/".$extension.".gif");
}
return $self->session->url->extras("fileIcons/unknown.gif");
my $self = shift;
my $filename = shift;
my $extension = $self->getFileExtension($filename);
if ($extension) {
my $path = $self->session->config->get("extrasPath").'/fileIcons/'.$extension.".gif";
if (-e $path) {
return $self->session->url->extras("fileIcons/".$extension.".gif");
}
}
return $self->session->url->extras("fileIcons/unknown.gif");
}
@ -941,6 +942,7 @@ sub tar {
my $self = shift;
my $filename = shift;
my $temp = shift || WebGUI::Storage->createTemp($self->session);
my $originalDir = cwd;
chdir $self->getPath or croak 'Unable to chdir to ' . $self->getPath . ": $!";
my @files = ();
find(sub { push(@files, $File::Find::name)}, ".");
@ -948,11 +950,11 @@ sub tar {
my $tar = Archive::Tar->new();
$tar->add_files(@files);
$tar->write($temp->getPath($filename),1);
}
else {
Archive::Tar->create_archive($temp->getPath($filename),1,@files);
}
chdir $originalDir;
return $temp;
}