Skip to content

Commit

Permalink
Merge pull request #445 from Atineon/fix_deleted_packages
Browse files Browse the repository at this point in the history
fix: deleted packages in deployment history
  • Loading branch information
charleneauger committed Dec 18, 2023
2 parents 638d32f + c53cdab commit db69c1b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Apache/Ocsinventory/Server/Capacities/Download/Inventory.pm
Expand Up @@ -92,6 +92,16 @@ sub update_history_diff{

my @alreadyhandled;

my @existing_packages;

my $query = $dbh->prepare('SELECT FILEID FROM download_available WHERE DELETED=0');

if( $query->execute() ){
while( my $row = $query->fetchrow_hashref ){
push @existing_packages, $row->{FILEID};
}
}

for my $l_xml (@$fromXml){
my $found = 0;
for my $i_db (0..(@{$fromDb}-1)){
Expand All @@ -105,8 +115,14 @@ sub update_history_diff{
}
}
if(!$found){
$dbh->do( 'INSERT INTO download_history(HARDWARE_ID, PKG_ID) VALUE(?,?)', {}, $hardwareId, $l_xml )
unless grep /\Q$l_xml\E/, @alreadyhandled;
for my $fileid (@existing_packages)
{
if($fileid eq $l_xml)
{
$dbh->do( 'INSERT INTO download_history(HARDWARE_ID, PKG_ID) VALUE(?,?)', {}, $hardwareId, $l_xml )
unless grep /\Q$l_xml\E/, @alreadyhandled;
}
}
}
push @alreadyhandled, $l_xml;
}
Expand Down

0 comments on commit db69c1b

Please sign in to comment.