Changeset 11660


Ignore:
Timestamp:
2006-04-20T11:14:52+12:00 (18 years ago)
Author:
kjdon
Message:

John T's fix for associated files and groupsize:

Heres a minor bug fix to docsave.pm so that it handles associated files
properly (relatively speaking) when groupsize is set. It just ensures
that all associated files end up in the same archive folder as the
doc.xml that refers to them.

Of course, this causes a problem if one or more associated files have
the same name. I suspect the actual bug lies somewhere else in
Greenstone where it assumes that the associated file must be relative to
the archive dir's OID rather than the OID of one of the documents within
a grouped doc.xml. In other words a grouped document HASH0102... will
always have its associated files loaded from the HASH0102... folder even
if the associated file were actually processed into HASH1c2f...,
HASH011e... etc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/docsave.pm

    r10538 r11660  
    334334}
    335335
    336      
     336# /**
     337#  */
    337338sub group_process {
     339
    338340    my $self = shift (@_);
    339341    my ($doc_obj) = @_;
    340    
    341342    my $outhandle = $self->{'outhandle'};
    342343
     
    349350
    350351    # opening a new file, or document has assoicated files => directory needed
    351     if (($open_new_file) || (scalar(@{$doc_obj->get_assoc_files()})>0)) {
    352 
    353     # get document's directory
    354     my $doc_dir = $self->get_doc_dir ($OID, $doc_obj->get_source_filename());
    355 
    356     # copy all the associated files, add this information as metadata
    357     # to the document
    358     $self->process_assoc_files ($doc_obj, $doc_dir);
    359 
    360 
    361     if ($open_new_file) {
    362         # only if opening new file
     352    if (($open_new_file) || (scalar(@{$doc_obj->get_assoc_files()})>0))
     353      {
     354        # The directory the archive file (doc.xml) and all associated files
     355        # should end up in
     356        my $doc_dir;
     357        # If we've determined its time for a new file, open it now
     358        if ($open_new_file || !defined($self->{'gs_doc_dir'}))
     359          {
     360            $doc_dir = $self->get_doc_dir ($OID, $doc_obj->get_source_filename());
     361            # only if opening new file
    363362        my $output_dir = $self->getoutputdir();
    364         my $doc_file
    365         = &util::filename_cat ($output_dir, $doc_dir, "doc.xml");
     363
     364        my $doc_file = &util::filename_cat ($output_dir, $doc_dir, "doc.xml");
    366365        my $short_doc_file = &util::filename_cat ($doc_dir, "doc.xml");
    367        
     366
    368367        if ($gs_count>0)
    369368        {
    370369        return if (!$self->close_file_output());
    371370        }
    372        
     371
    373372        if (!open (OUTDOC, ">$doc_file")) {
    374373        print $outhandle "docsave::group_process could not write to file $doc_file\n";
     
    378377        $self->{'gs_short_filename'} = $short_doc_file;
    379378        $self->{'gs_OID'} = $OID;
     379            $self->{'gs_doc_dir'} = $doc_dir;
    380380
    381381        $self->output_xml_header('docsave::OUTDOC');
    382382    }
     383        # Otherwise load the same archive document directory used last time
     384        else
     385          {
     386            $doc_dir = $self->{'gs_doc_dir'};
     387          }
     388    # copy all the associated files, add this information as metadata
     389    # to the document
     390        print STDERR "Writing associated files to $doc_dir\n";
     391    $self->process_assoc_files ($doc_obj, $doc_dir);
    383392    }
    384393
Note: See TracChangeset for help on using the changeset viewer.