Changeset 23280


Ignore:
Timestamp:
11/03/10 10:48:50 (10 years ago)
Author:
kjdon
Message:

fixed this plugin up for incremental import. need to set gsdlzipfilename for all files unpacked into tmp dir. Also, if incremental, need to add all the files unpacked to the new files list so they get processed. If the zip file hasn't changed, then won't get into this read method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/ZIPPlugin.pm

    r23261 r23280  
    8585}
    8686
     87sub begin {
     88    my $self = shift (@_);
     89    my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
     90
     91    # Are we actually incremental and doing import?
     92    my $proc_package_name = ref $processor;
     93    if ($proc_package_name !~ /buildproc$/ && $self->{'incremental'} == 1) {
     94        # Get the infodbtype value for this collection from the arcinfo object
     95        my $infodbtype = $processor->getoutputinfo()->{'infodbtype'};
     96    $infodbtype = "gdbm" if $infodbtype eq "gdbm-txtgz"; # in archives, cannot use txtgz version
     97    my $output_dir = $processor->getoutputdir();
     98        my $archives_inf = &dbutil::get_infodb_file_path($infodbtype, "archiveinf-doc", $output_dir);
     99
     100    if ( -e $archives_inf ) {
     101        $self->{'actually_incremental'} = 1;
     102    }
     103    }
     104   
     105   
     106}
    87107# this is a recursive plugin
    88108sub is_recursive {
     
    108128    return undef unless $self->can_process_this_file($filename_full_path);
    109129   
    110     my $tmpdir = &util::get_tmp_filename ();
     130    my $tmpdir = $file;
     131    $tmpdir =~ s/\.[^\.]*//;
     132    $tmpdir = &util::rename_file($tmpdir, $self->{'file_rename_method'});
     133    $tmpdir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "tmp", $tmpdir);
    111134    &util::mk_all_dir ($tmpdir);
    112135   
     
    136159    &plugin::file_block_read ($pluginfo, "", $tmpdir,
    137160                  $block_hash, $metadata, $gli);
    138     my $numdocs = &plugin::read ($pluginfo, "", $tmpdir, $block_hash, $metadata, $processor, $maxdocs, $total_count, $gli);
     161
     162    # if we are incremental, then we need to add all the files in the tmp folder into the new_files list otherwise they won't get processed.
     163    if ($self->{'actually_incremental'}) {
     164    my @file_list = ();
     165    &inexport::add_dir_contents_to_list($tmpdir, \@file_list);
     166    foreach my $file (@file_list) {
     167        $block_hash->{'new_files'}->{$file} = 1;
     168    }
     169    }
     170    # all files in the tmp folder need to get the gsdlzipfilenmae metadata
     171    my $this_metadata = {};
     172    $this_metadata->{"gsdlzipfilename"} = $filename_full_path;
     173    &metadatautil::combine_metadata_structures($this_metadata, $metadata);
     174    my $numdocs = &plugin::read ($pluginfo, "", $tmpdir, $block_hash, $this_metadata, $processor, $maxdocs, $total_count, $gli);
    139175    &util::rm_r ($tmpdir);
    140176   
     
    191227}
    192228
     229
     230
    1932311;
Note: See TracChangeset for help on using the changeset viewer.