Open jagarsoft opened 2 years ago
The problem was detected in line that skips . and .. entries of the root directory in -d flag
Where it says:
next if $file =~ /^..?$/ ;
must say:
next if $file =~ /^\.\.?$/ ;
That's all folks! ;-)
This can be reproduced like this:
mkdir computer
mkdir computer\0
mkdir computer\1
mkdir computer\2
echo 01.xml > computer\0\01.xml
echo 02.xml > computer\0\02.xml
echo 10.xml > computer\1\10.xml
echo 11.xml > computer\1\11.xml
echo 20.xml > computer\2\20.xml
echo 21.xml > computer\2\21.xml
mkdir computer\100
echo 100.xml > computer\100\100.xml
echo 101.xml > computer\100\101.xml
Run Injector:
perl.exe fusioninventory-injector -v -R -d computer -u http://localhost
Outputs:
In computer
computer/.
computer/..
computer/0
computer/1
computer/100
. and .. skiped
It's a DIR c:/computer/100
In computer/100
computer/100/.
computer/100/..
computer/100/100.xml
. and .. skipped
It's a FILE c:/computer/100/100.xml
Loading c:/computer/100/100.xml...ERROR: 500 Can't connect to localhost:80
Next DIR
computer/100/101.xml
. and .. skipped
It's a FILE c:/computer/100/101.xml
Loading c:/computer/100/101.xml...ERROR: 500 Can't connect to localhost:80
Next DIR
Next DIR
computer/2
These elements were not sent:
c:/computer/100/100.xml
c:/computer/100/101.xml
With this warns ;-)
sub loaddirectory {
my ($directory) = @_;
warn "In $directory\n";
die "directory $directory does not exist\n" unless -d $directory;
die "directory $directory is not readable\n" unless -r $directory;
opendir (my $handle, $directory)
or die "can't open directory $directory: $ERRNO\n";
foreach my $file (readdir($handle)) {
warn "$directory/$file\n";
next if $file =~ /^\.\.?$/ ;
warn ". and .. skipped\n";
if (-d "$directory/$file") {
warn "It's a DIR $directory/$file\n";
loaddirectory("$directory/$file") if ($options->{recursive});
} else {
warn "It's a FILE $directory/$file\n";
loadfile("$directory/$file") if $file =~ /\.(?:ocs|xml)$/;
}
warn "Next DIR\n";
}
closedir $handle;
}
When I run Injector script in order to sent them to a server, it reads from computer/ directory what has a set of directories based in first digit of XML file, like this: computer/0/1.xml computer/0/2.xml ... computer/1/10.xml computer/1/11.xml ... computer/2/20.xml computer/2/21.xml etc
However, directories from 0 to 99 are skiped.