Subversion Repositories DevTools

Rev

Rev 4612 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4612 Rev 4618
Line 428... Line 428...
428
    #
428
    #
429
    Error("Sanity Check Failure. PVID") unless($opt_pvid eq $xml->{package}{pvid});
429
    Error("Sanity Check Failure. PVID") unless($opt_pvid eq $xml->{package}{pvid});
430
    Error("Sanity Check Failure. Name") unless($opt_pname eq $xml->{package}{name});
430
    Error("Sanity Check Failure. Name") unless($opt_pname eq $xml->{package}{name});
431
    Error("Sanity Check Failure. Version") unless($opt_pversion eq $xml->{package}{version});
431
    Error("Sanity Check Failure. Version") unless($opt_pversion eq $xml->{package}{version});
432
    Error("Sanity Check Failure. File Section") unless(exists $xml->{files}{file});
432
    Error("Sanity Check Failure. File Section") unless(exists $xml->{files}{file});
433
#    DebugDumpData("XML DATA", \$xml);
433
    #DebugDumpData("XML DATA", \$xml);
434
 
434
 
435
    #
435
    #
436
    #   Delete any existing entry(s)
436
    #   Delete any existing entry(s)
437
    #
437
    #
438
    updateRmFilesDelete();
438
    updateRmFilesDelete();
439
 
439
 
440
    #
440
    #
441
    #   Scan each entry and pump required data into the RM Database
441
    #   Scan each entry and pump required data into the RM Database
-
 
442
    #   The {files}{file} may be either an array or a hash XMLin appears to
-
 
443
    #   make some decision as to which it will be, and I can't control it
442
    #
444
    #
-
 
445
    #   When it does happen the hash key is the 'name' element
-
 
446
    #
-
 
447
    if (ref($xml->{files}{file}) eq 'HASH')
-
 
448
    {
-
 
449
        Verbose("Convert file hash to an array");
-
 
450
        my @nowArray;
-
 
451
        foreach my $name ( keys %{$xml->{files}{file}})
-
 
452
        {
-
 
453
            my $entry = $xml->{files}{file}{$name};
-
 
454
            $entry->{name} = $name;
-
 
455
            push @nowArray, $entry;
-
 
456
        }
-
 
457
        $xml->{files}{file} = \@nowArray
-
 
458
    }
-
 
459
    Error("Sanity Check Failure. File Section not an ARRAY") unless(ref($xml->{files}{file}) eq 'ARRAY');
-
 
460
 
-
 
461
    #
-
 
462
    #   Release Manager Database will barf if there are duplicate entries
-
 
463
    #   Maintain a hash of items processed, and only process each once
-
 
464
    #
-
 
465
    my %fullNameSeen;
-
 
466
 
443
    $updateRmFilesData = ""; 
467
    $updateRmFilesData = ""; 
444
    foreach my $entry (@{$xml->{files}{file}})
468
    foreach my $entry (@{$xml->{files}{file}})
445
    {
469
    {
446
        #DebugDumpData("Entry", $entry);
-
 
447
 
-
 
448
        #
470
        #
449
        #   Clean up the data
471
        #   Clean up the data
450
        #
472
        #
451
        my $fname = $entry->{name} || '';
473
        my $fname = $entry->{name} || '';
452
        my $fpath  = $entry->{path} || '';
474
        my $fpath  = $entry->{path} || '';
453
        my $fsize  = $entry->{size} || 0;
475
        my $fsize  = $entry->{size} || 0;
454
        my $fmd5  = $entry->{md5sum} || '';
476
        my $fmd5  = $entry->{md5sum} || '';
455
 
-
 
456
        $fpath =~ s~/$~~ unless $fname;
477
        $fpath =~ s~/$~~ unless $fname;
457
 
478
 
-
 
479
        unless( $fullNameSeen{$fpath}{$fname} )
458
        #
480
        {
-
 
481
            $fullNameSeen{$fpath}{$fname} = 1;
-
 
482
 
-
 
483
            #
459
        #   Create SQL fragment for the insert
484
            #   Create SQL fragment for the insert
460
        #
485
            #
461
        $eCount++;
486
            $eCount++;
462
        my $entry = " INTO release_manager.release_components ( pv_id, file_name, file_path, byte_size, crc_cksum, crc_modcrc ) " .
487
            my $entry = " INTO release_manager.release_components ( pv_id, file_name, file_path, byte_size, crc_cksum, crc_modcrc ) " .
463
                    " VALUES ( $opt_pvid, '$fname', '$fpath',$fsize , '$fmd5', '')";
488
                        " VALUES ( $opt_pvid, '$fname', '$fpath',$fsize , '$fmd5', '')";
464
        $updateRmFilesData .= $entry;
489
            $updateRmFilesData .= $entry;
465
 
490
 
466
        # The size of the aggregation is key to performance
491
            # The size of the aggregation is key to performance
467
        # Too big is as bad as too small
492
            # Too big is as bad as too small
468
        if (length($updateRmFilesData) > 10000)
493
            if (length($updateRmFilesData) > 10000)
-
 
494
            {
-
 
495
                updateRmFilesInsert();
-
 
496
            }
-
 
497
        }
-
 
498
        else
469
        {
499
        {
470
            updateRmFilesInsert();
500
            Warning("Multiple file entries for: $fpath $fname");
471
        }
501
        }
472
    }
502
    }
473
    updateRmFilesInsert();
503
    updateRmFilesInsert();
474
    Verbose ("Inserted $eCount entries into Release_Components");
504
    Verbose ("Inserted $eCount entries into Release_Components");
475
}
505
}