Changeset 23182


Ignore:
Timestamp:
2010-10-20T13:12:24+13:00 (11 years ago)
Author:
kjdon
Message:

fixed up bug with deleting assoc files. Was fine for a delete, but for an update, need to delete the old ones *before* adding the new ones. And also, don't delete the lucene text doc when updating. Presumably it has already been overwritten with the correct version

Location:
main/trunk/greenstone2/perllib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/basebuildproc.pm

    r23176 r23182  
    406406    $archivedir = $dir;
    407407
     408    if ($edit_mode eq "delete") {
     409        # record this doc so we don't process the reconstructed doc later
     410        $self->{'dont_process_reconstructed'}->{$doc_obj->get_OID()} = 1;
     411        # we don't need to do anything else for the info database for a deleted document. The infodb starts from scratch each time, so no deletion is necessary
     412        $self->delete_assoc_files ($archivedir, "delete");
     413        return;
     414    }
     415    if ($edit_mode eq "update") {
     416        # we don't want to process the reconstructed doc later, but we will process this version now.
     417        $self->{'dont_process_reconstructed'}->{$doc_obj->get_OID()} = 1;
     418        # delete the old assoc files as they may have changed
     419        $self->delete_assoc_files ($archivedir, "update");
     420    }
     421   
    408422    # resolve the final filenames of the files associated with this document
     423    # now save the new assoc files for an update/new doc.
    409424    $self->assoc_files ($doc_obj, $archivedir);
    410425    }
     
    414429    my $top_section = $doc_obj->get_top_section();
    415430    $archivedir = $doc_obj->get_metadata_element($top_section,"archivedir");
    416     }
    417 
    418     if ($edit_mode eq "delete") {
    419     # record this doc so we don't process the reconstructed doc later
    420     $self->{'dont_process_reconstructed'}->{$doc_obj->get_OID()} = 1;
    421     # we don't need to do anything else for the info database for a deleted document. The infodb starts from scratch each time, so no deletion is necessary
    422     $self->delete_assoc_files ($archivedir);
    423     return;
    424     }
    425    
    426     if ($edit_mode eq "update") {
    427     # we don't want to process the reconstructed doc later, but we will process this version now.
    428     $self->{'dont_process_reconstructed'}->{$doc_obj->get_OID()} = 1;
    429     $self->delete_assoc_files ($archivedir);
    430431    }
    431432
     
    819820{
    820821    my $self = shift (@_);
    821     my ($archivedir) = @_;
     822    my ($archivedir, $edit_mode) = @_;
    822823
    823824    my $assoc_dir = &util::filename_cat($self->{'assocdir'}, $archivedir);
  • main/trunk/greenstone2/perllib/lucenebuildproc.pm

    r23181 r23182  
    572572{
    573573    my $self = shift (@_);
    574     my ($archivedir) = @_;
     574    my ($archivedir, $edit_mode) = @_;
    575575
    576576    $self->basebuildproc::delete_assoc_files(@_);
    577577   
    578     my $assoc_dir = &util::filename_cat($self->{'build_dir'},"text", $archivedir);
    579     if (-d $assoc_dir) {
    580     &util::rm_r($assoc_dir);
    581     }
     578    if ($edit_mode eq "delete") {
     579    # if we are deleting the doc, then also delete the lucene text  version
     580    my $assoc_dir = &util::filename_cat($self->{'build_dir'},"text", $archivedir);
     581    if (-d $assoc_dir) {
     582        &util::rm_r($assoc_dir);
     583    }
     584    }
    582585}
    583586
Note: See TracChangeset for help on using the changeset viewer.