Skip to content

Commit

Permalink
fix: Fix dedicated modules error loading on windows
Browse files Browse the repository at this point in the history
Closes #780
  • Loading branch information
g-bougard committed Oct 8, 2024
1 parent 23984da commit fdeb7fa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Revision history for GLPI agent

1.12 not yet released

core:
* fix #780: Avoid module loading path check error on windows if path includes a
parenthesis

inventory:
* Fix rare windows perl error during drives, ipv6 network or videos inventory

Expand Down
4 changes: 3 additions & 1 deletion lib/GLPI/Agent/Tools/PartNumber.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ sub new {
my %priority = ();
my ($_classpath) = $INC{module2file(__PACKAGE__)} =~ /^(.*)\.pm$/;
$_classpath =~ s{\\}{/}g if $OSNAME eq 'MSWin32';
my $subclass_path_re = qr/$_classpath\/(\S+)\.pm$/;
my ($_modulepath) = module2file(__PACKAGE__) =~ /^(.*)\.pm$/;
$_modulepath =~ s{\\}{/}g if $OSNAME eq 'MSWin32';
my $subclass_path_re = qr/$_modulepath\/(\S+)\.pm$/;
foreach my $file (File::Glob::bsd_glob("$_classpath/*.pm")) {
$file =~ s{\\}{/}g if $OSNAME eq 'MSWin32';
my ($class) = $file =~ $subclass_path_re
Expand Down
6 changes: 4 additions & 2 deletions lib/GLPI/Agent/Tools/USB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ sub new {

# Load any related sub-module
my ($sub_modules_path) = $INC{module2file(__PACKAGE__)} =~ /(.*)\.pm/;
$sub_modules_path =~ s{\\}{/}g if $OSNAME eq 'MSWin32';
my ($sub_path_check) = module2file(__PACKAGE__) =~ /(.*)\.pm/;
$sub_path_check =~ s{\\}{/}g if $OSNAME eq 'MSWin32';

foreach my $file (File::Glob::bsd_glob("$sub_modules_path/*.pm")) {
if ($OSNAME eq 'MSWin32') {
$file =~ s{\\}{/}g;
$sub_modules_path =~ s{\\}{/}g;
}
next unless $file =~ m{$sub_modules_path/(\S+)\.pm$};
next unless $file =~ m{$sub_path_check/(\S+)\.pm$};

my $module = __PACKAGE__ . "::" . $1;
# reload can be set by unittests
Expand Down

0 comments on commit fdeb7fa

Please sign in to comment.