Added more extensive logging to file system problems.
This commit is contained in:
parent
e368224215
commit
f9f6bc6497
4 changed files with 44 additions and 35 deletions
|
|
@ -71,7 +71,7 @@ sub _createThumbnail {
|
|||
if ($hasImageMagick && isIn($_[0]->getType, qw(jpg jpeg gif png tif tiff bmp))) {
|
||||
$image = Image::Magick->new;
|
||||
$error = $image->Read($_[0]->getPath);
|
||||
WebGUI::ErrorHandler::warn($error) if $error;
|
||||
WebGUI::ErrorHandler::warn("Couldn't read image for thumnail creation: ".$error) if $error;
|
||||
($x, $y) = $image->Get('width','height');
|
||||
$n = $_[1] || $session{setting}{thumbnailSize};
|
||||
$r = $x>$y ? $x / $n : $y / $n;
|
||||
|
|
@ -81,7 +81,7 @@ sub _createThumbnail {
|
|||
} else {
|
||||
$error = $image->Write($_[0]->{_node}->getPath.'/thumb-'.$_[0]->getFilename);
|
||||
}
|
||||
WebGUI::ErrorHandler::warning($error) if $error;
|
||||
WebGUI::ErrorHandler::warning("Couldn't create thumbnail: ".$error) if $error;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ sub copy {
|
|||
$b = FileHandle->new(">".$newNode->getPath.'/'.$_[0]->getFilename);
|
||||
if (defined $b) {
|
||||
binmode($b);
|
||||
cp($a,$b);
|
||||
cp($a,$b) or WebGUI::ErrorHandler::warn("Couldn't copy attachment: ".$newNode->getPath.'/'.$_[0]->getFilename." :".$!);
|
||||
$b->close;
|
||||
}
|
||||
$a->close;
|
||||
|
|
@ -258,7 +258,9 @@ sub getIcon {
|
|||
=cut
|
||||
|
||||
sub getPath {
|
||||
return $_[0]->{_node}->getPath.'/'.$_[0]->getFilename;
|
||||
my ($slash);
|
||||
$slash = ($^O =~ /Win/i) ? "\\" : "/";
|
||||
return $_[0]->{_node}->getPath.$slash.$_[0]->getFilename;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -271,8 +273,9 @@ sub getPath {
|
|||
=cut
|
||||
|
||||
sub getSize {
|
||||
my ($size);
|
||||
my (@attributes) = stat($_[0]->{_node}->getPath.'/'.$_[0]->getFilename);
|
||||
my ($size, $slash);
|
||||
$slash = ($^O =~ /Win/i) ? "\\" : "/";
|
||||
my (@attributes) = stat($_[0]->{_node}->getPath.$slash.$_[0]->getFilename);
|
||||
if ($attributes[7] > 1048576) {
|
||||
$size = round($attributes[7]/1048576);
|
||||
$size .= 'mb';
|
||||
|
|
@ -298,10 +301,12 @@ sub getSize {
|
|||
=cut
|
||||
|
||||
sub getThumbnail {
|
||||
my ($slash);
|
||||
$slash = ($^O =~ /Win/i) ? "\\" : "/";
|
||||
if ($hasImageMagick && isIn($_[0]->getType, qw(jpg jpeg gif png))) {
|
||||
return $_[0]->{_node}->getURL.'/thumb-'.$_[0]->getFilename;
|
||||
return $_[0]->{_node}->getURL.$slash.'thumb-'.$_[0]->getFilename;
|
||||
} elsif ($hasImageMagick && isIn($_[0]->getType, qw(tif tiff bmp))) {
|
||||
return $_[0]->{_node}->getURL.'/thumb-'.$_[0]->getFilename.'.png';
|
||||
return $_[0]->{_node}->getURL.$slash.'thumb-'.$_[0]->getFilename.'.png';
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
|
@ -380,7 +385,9 @@ sub new {
|
|||
=cut
|
||||
|
||||
sub rename {
|
||||
rename $_[0]->getPath, $_[0]->{_node}->getPath.'/'.$_[1];
|
||||
my ($slash);
|
||||
$slash = ($^O =~ /Win/i) ? "\\" : "/";
|
||||
rename $_[0]->getPath, $_[0]->{_node}->getPath.$slash.$_[1];
|
||||
$_[0]->{_filename} = $_[1];
|
||||
}
|
||||
|
||||
|
|
@ -432,7 +439,7 @@ sub save {
|
|||
close($file);
|
||||
_createThumbnail($_[0],$_[2]);
|
||||
} else {
|
||||
WebGUI::ErrorHandler::warn("Couldn't open file ".$_[0]->getPath." for writing.");
|
||||
WebGUI::ErrorHandler::warn("Couldn't open file ".$_[0]->getPath." for writing due to error: ".$!);
|
||||
$_[0]->{_filename} = "";
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package WebGUI::Node;
|
|||
use File::Path;
|
||||
use POSIX;
|
||||
use strict;
|
||||
use WebGUI::ErrorHandler;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -56,9 +57,19 @@ use WebGUI::Session;
|
|||
=cut
|
||||
|
||||
sub create {
|
||||
mkdir($session{setting}{attachmentDirectoryLocal}.'/'.$_[0]->{_node1},0755);
|
||||
my ($slash, $node);
|
||||
$slash = ($^O =~ /Win/i) ? "\\" : "/";
|
||||
$node = $session{setting}{attachmentDirectoryLocal}.$slash.$_[0]->{_node1};
|
||||
mkdir($node);
|
||||
unless ($! eq "File exists" || $! eq "") {
|
||||
WebGUI::ErrorHandler::warn("Couldn't create node: $node : $!");
|
||||
}
|
||||
if ($_[0]->{_node2} ne "") {
|
||||
mkdir($session{setting}{attachmentDirectoryLocal}.'/'.$_[0]->{_node1}.'/'.$_[0]->{_node2},0755);
|
||||
$node = $session{setting}{attachmentDirectoryLocal}.$slash.$_[0]->{_node1}.$slash.$_[0]->{_node2};
|
||||
mkdir($node);
|
||||
unless ($! eq "File exists" || $! eq "") {
|
||||
WebGUI::ErrorHandler::warn("Couldn't create node: $node : $!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,10 +95,11 @@ sub delete {
|
|||
=cut
|
||||
|
||||
sub getPath {
|
||||
my ($path);
|
||||
$path = $session{setting}{attachmentDirectoryLocal}.'/'.$_[0]->{_node1};
|
||||
my ($path,$slash);
|
||||
$slash = ($^O =~ /Win/i) ? "\\" : "/";
|
||||
$path = $session{setting}{attachmentDirectoryLocal}.$slash.$_[0]->{_node1};
|
||||
if ($_[0]->{_node2} ne "") {
|
||||
$path .= '/'.$_[0]->{_node2};
|
||||
$path .= $slash.$_[0]->{_node2};
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,12 +106,9 @@ sub _getUserInfo {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub _loadMacros {
|
||||
my ($namespace, $cmd, @files, $file, $dir);
|
||||
if ($^O =~ /Win/i) {
|
||||
$dir = "\\lib\\WebGUI\\Macro";
|
||||
} else {
|
||||
$dir = "/lib/WebGUI/Macro";
|
||||
}
|
||||
my ($slash, $namespace, $cmd, @files, $file, $dir);
|
||||
$slash = ($^O =~ /Win/i) ? "\\" : "/";
|
||||
$dir = $slash."lib".$slash."WebGUI".$slash."Macro";
|
||||
opendir (DIR,$session{config}{webguiRoot}.$dir) or WebGUI::ErrorHandler::fatalError("Can't open macro directory!");
|
||||
@files = readdir(DIR);
|
||||
foreach $file (@files) {
|
||||
|
|
@ -128,12 +125,9 @@ sub _loadMacros {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub _loadWobjects {
|
||||
my ($dir, @files, $file, $cmd, $namespace);
|
||||
if ($^O =~ /Win/i) {
|
||||
$dir = "\\lib\\WebGUI\\Wobject";
|
||||
} else {
|
||||
$dir = "/lib/WebGUI/Wobject";
|
||||
}
|
||||
my ($dir, @files, $slash, $file, $cmd, $namespace);
|
||||
$slash = ($^O =~ /Win/i) ? "\\" : "/";
|
||||
$dir = $slash."lib".$slash."WebGUI".$slash."Wobject";
|
||||
opendir (DIR,$session{config}{webguiRoot}.$dir) or WebGUI::ErrorHandler::fatalError("Can't open wobject directory!");
|
||||
@files = readdir(DIR);
|
||||
foreach $file (@files) {
|
||||
|
|
|
|||
|
|
@ -21,14 +21,10 @@ use strict qw(subs vars);
|
|||
use Data::Config;
|
||||
|
||||
|
||||
my (@files, $cmd, $namespace, $i, $file, $confdir, @plugins, $plugin, $plugdir);
|
||||
if ($^O =~ /Win/i) {
|
||||
$confdir = $webguiRoot."\\etc\\";
|
||||
$plugdir = $webguiRoot."\\sbin\\Hourly\\";
|
||||
} else {
|
||||
$confdir = $webguiRoot."/etc/";
|
||||
$plugdir = $webguiRoot."/sbin/Hourly/";
|
||||
}
|
||||
my (@files, $cmd, $namespace, $i, $file, $slash, $confdir, @plugins, $plugin, $plugdir);
|
||||
$slash = ($^O =~ /Win/i) ? "\\" : "/";
|
||||
$confdir = $webguiRoot.$slash."etc".$slash;
|
||||
$plugdir = $webguiRoot.$slash."sbin".$slash."Hourly".$slash;
|
||||
|
||||
if (opendir (PLUGDIR,$plugdir)) {
|
||||
@files = readdir(PLUGDIR);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue