source: gsdl/trunk/perllib/plugins/DirectoryPlugin.pm@ 20605

Last change on this file since 20605 was 20577, checked in by davidb, 15 years ago

Changes to support new incremental_mode variable, and to track metadata.xml files more closely so incremental building works when a document is first build without any metadata attached, then then in a subsequent build has metadata from such a source as metadata.xml added.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 20.4 KB
RevLine 
[537]1###########################################################################
2#
[15870]3# DirectoryPlugin.pm --
[537]4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
[15870]26# DirectoryPlugin is a plugin which recurses through directories processing
27# each file it finds - which basically means passing it down the plugin
28# pipeline
[4]29
[15870]30package DirectoryPlugin;
[2228]31
[17738]32use PrintInfo;
[4]33use plugin;
[136]34use util;
[13188]35use metadatautil;
[4]36
[8737]37use File::Basename;
[10254]38use strict;
39no strict 'refs';
[15870]40no strict 'subs';
41
[13545]42use Encode;
[4]43
44BEGIN {
[17738]45 @DirectoryPlugin::ISA = ('PrintInfo');
[4]46}
47
[4744]48my $arguments =
49 [ { 'name' => "block_exp",
[15870]50 'desc' => "{BasePlugin.block_exp}",
[6408]51 'type' => "regexp",
[4744]52 'deft' => &get_default_block_exp(),
53 'reqd' => "no" },
[13417]54 # this option has been deprecated. leave it here for now so we can warn people not to use it
[4744]55 { 'name' => "use_metadata_files",
[15870]56 'desc' => "{DirectoryPlugin.use_metadata_files}",
[4744]57 'type' => "flag",
[13188]58 'reqd' => "no",
59 'hiddengli' => "yes" },
[7686]60 { 'name' => "recheck_directories",
[15870]61 'desc' => "{DirectoryPlugin.recheck_directories}",
[7686]62 'type' => "flag",
[4744]63 'reqd' => "no" } ];
[13188]64
[15870]65my $options = { 'name' => "DirectoryPlugin",
66 'desc' => "{DirectoryPlugin.desc}",
[6408]67 'abstract' => "no",
[4744]68 'inherits' => "yes",
69 'args' => $arguments };
[3540]70
[4]71sub new {
[10218]72 my ($class) = shift (@_);
73 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
74 push(@$pluginlist, $class);
[3540]75
[15870]76 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
77 push(@{$hashArgOptLists->{"OptList"}},$options);
[10218]78
[17738]79 my $self = new PrintInfo($pluginlist, $inputargs, $hashArgOptLists);
[13188]80
81 if ($self->{'info_only'}) {
82 # don't worry about any options or initialisations etc
83 return bless $self, $class;
84 }
85
86 # we have left this option in so we can warn people who are still using it
[2813]87 if ($self->{'use_metadata_files'}) {
[15870]88 die "ERROR: DirectoryPlugin -use_metadata_files option has been deprecated. Please remove the option and add MetadataXMLPlug to your plugin list instead!\n";
[2813]89 }
[16391]90
[17738]91 $self->{'num_processed'} = 0;
92 $self->{'num_not_processed'} = 0;
93 $self->{'num_blocked'} = 0;
94 $self->{'num_archives'} = 0;
95
[8737]96 $self->{'subdir_extrametakeys'} = {};
97
[4]98 return bless $self, $class;
99}
100
[17738]101# called once, at the start of processing
102sub init {
103 my $self = shift (@_);
104 my ($verbosity, $outhandle, $failhandle) = @_;
105
106 # verbosity is passed through from the processor
107 $self->{'verbosity'} = $verbosity;
108
109 # as are the outhandle and failhandle
110 $self->{'outhandle'} = $outhandle if defined $outhandle;
111 $self->{'failhandle'} = $failhandle;
112
113}
114
115# called once, after all passes have finished
116sub deinit {
117 my ($self) = @_;
118
119}
120
121# called at the beginning of each plugin pass (import has one, building has many)
[10156]122sub begin {
123 my $self = shift (@_);
124 my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
125
126 my $proc_package_name = ref $processor;
127
[12969]128 if ($proc_package_name !~ /buildproc$/ && $self->{'incremental'} == 1) {
[10156]129
[12969]130 # Only lookup timestamp info for import.pl, and only if incremental is set
[10156]131
132 my $output_dir = $processor->getoutputdir();
[18441]133## my $archives_inf = &util::filename_cat($output_dir,"archives.inf");
[18659]134 my $doc_db = "archiveinf-doc.gdb";
[18441]135 my $archives_inf = &util::filename_cat($output_dir,$doc_db);
136
[10156]137 if ( -e $archives_inf ) {
138 $self->{'inf_timestamp'} = -M $archives_inf;
139 }
140 }
141}
142
[17738]143# called at the end of each plugin pass
[15870]144sub end {
[17738]145 my ($self) = shift (@_);
[10156]146
[15870]147}
148
149
[17738]150
[4]151# return 1 if this class might recurse using $pluginfo
152sub is_recursive {
153 my $self = shift (@_);
[2813]154
[4]155 return 1;
156}
157
[2228]158sub get_default_block_exp {
159 my $self = shift (@_);
[2813]160
[19178]161 return '(?i)(CVS|\.svn|Thumbs\.db|OIDcount|~)$';
[2228]162}
163
[16391]164sub check_directory_path {
[2228]165
[16391]166 my $self = shift(@_);
167 my ($dirname) = @_;
[2813]168
[2228]169 return undef unless (-d $dirname);
[16391]170
[2228]171 return 0 if ($self->{'block_exp'} ne "" && $dirname =~ /$self->{'block_exp'}/);
[7932]172
[16391]173 my $outhandle = $self->{'outhandle'};
174
[2228]175 # check to make sure we're not reading the archives or index directory
176 my $gsdlhome = quotemeta($ENV{'GSDLHOME'});
[2813]177 if ($dirname =~ m/^$gsdlhome\/.*?\/import.*?\/(archives|index)$/) {
[15870]178 print $outhandle "DirectoryPlugin: $dirname appears to be a reference to a Greenstone collection, skipping.\n";
[2228]179 return 0;
[1755]180 }
[2813]181
[1755]182 # check to see we haven't got a cyclic path...
183 if ($dirname =~ m%(/.*){,41}%) {
[15870]184 print $outhandle "DirectoryPlugin: $dirname is 40 directories deep, is this a recursive path? if not increase constant in DirectoryPlugin.pm.\n";
[2228]185 return 0;
[1755]186 }
[2813]187
[1755]188 # check to see we haven't got a cyclic path...
189 if ($dirname =~ m%.*?import/(.+?)/import/\1.*%) {
[15870]190 print $outhandle "DirectoryPlugin: $dirname appears to be in a recursive loop...\n";
[2228]191 return 0;
[1755]192 }
[16391]193
194 return 1;
195}
196
197# this may be called more than once
198sub sort_out_associated_files {
199
200 my $self = shift (@_);
201 my ($block_hash) = @_;
202 if (!scalar (keys %{$block_hash->{'shared_fileroot'}})) {
203 return;
204 }
205
206 $self->{'assocfile_info'} = {} unless defined $self->{'assocfile_info'};
207 my $metadata = $self->{'assocfile_info'};
208 foreach my $prefix (keys %{$block_hash->{'shared_fileroot'}}) {
209 my $record = $block_hash->{'shared_fileroot'}->{$prefix};
210
211 my $tie_to = $record->{'tie_to'};
212 my $exts = $record->{'exts'};
213
214 if ((defined $tie_to) && (scalar (keys %$exts) > 0)) {
215 # set up fileblocks and assocfile_tobe
216 my $base_file = "$prefix$tie_to";
217 $metadata->{$base_file} = {} unless defined $metadata->{$base_file};
218 my $base_file_metadata = $metadata->{$base_file};
219
220 $base_file_metadata->{'gsdlassocfile_tobe'} = [] unless defined $base_file_metadata->{'gsdlassocfile_tobe'};
221 my $assoc_tobe = $base_file_metadata->{'gsdlassocfile_tobe'};
222 foreach my $e (keys %$exts) {
223 # block the file
224 $block_hash->{'file_blocks'}->{"$prefix$e"} = 1;
225 # set up as an associatd file
226 print STDERR " $self->{'plugin_type'}: Associating $prefix$e with $tie_to version\n";
227 my $mime_type = ""; # let system auto detect this
228 push(@$assoc_tobe,"$prefix$e:$mime_type:");
229
230 }
231 }
232 } # foreach record
233
234 $block_hash->{'shared_fileroot'} = undef;
235 $block_hash->{'shared_fileroot'} = {};
236
237}
238
239
240# do block exp OR special blocking ???
241
242sub file_is_blocked {
243 my $self = shift (@_);
244 my ($block_hash, $filename_full_path) = @_;
245
246 if (defined $block_hash->{'file_blocks'}->{$filename_full_path}) {
247 $self->{'num_blocked'} ++;
248 return 1;
249 }
250 # check Directory plugin's own block_exp
251 if ($self->{'block_exp'} ne "" && $filename_full_path =~ /$self->{'block_exp'}/) {
252 $self->{'num_blocked'} ++;
253 return 1; # blocked
254 }
255 return 0;
256}
257
258
259
260sub file_block_read {
261 my $self = shift (@_);
262 my ($pluginfo, $base_dir, $file, $block_hash, $metadata, $gli) = @_;
263
264 my $outhandle = $self->{'outhandle'};
265 my $verbosity = $self->{'verbosity'};
[2813]266
[16391]267 # Calculate the directory name and ensure it is a directory and
268 # that it is not explicitly blocked.
269 my $dirname = $file;
270 $dirname = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/;
271
272 my $directory_ok = $self->check_directory_path($dirname);
273 return $directory_ok unless (defined $directory_ok && $directory_ok == 1);
274
[18523]275 print $outhandle "Global file scan checking directory: $dirname\n";
276
[18441]277 $block_hash->{'all_files'} = {} unless defined $block_hash->{'all_files'};
[20577]278 $block_hash->{'metadata_files'} = {} unless defined $block_hash->{'metadata_files'};
[18441]279
[16391]280 $block_hash->{'file_blocks'} = {} unless defined $block_hash->{'file_blocks'};
281 $block_hash->{'shared_fileroot'} = {} unless defined $block_hash->{'shared_fileroot'};
282
283 # Recur over directory contents.
284 my (@dir, $subfile);
285 #my $count = 0;
286
287 print $outhandle "DirectoryPlugin block: getting directory $dirname\n" if ($verbosity > 2);
288
289 # find all the files in the directory
290 if (!opendir (DIR, $dirname)) {
291 if ($gli) {
292 print STDERR "<ProcessingError n='$file' r='Could not read directory $dirname'>\n";
293 }
294 print $outhandle "DirectoryPlugin: WARNING - couldn't read directory $dirname\n";
295 return -1; # error in processing
296 }
297 @dir = readdir (DIR);
298 closedir (DIR);
299
300 for (my $i = 0; $i < scalar(@dir); $i++) {
301 my $subfile = $dir[$i];
302 my $this_file_base_dir = $base_dir;
303 next if ($subfile =~ m/^\.\.?$/);
304
305 # Recursively read each $subfile
306 print $outhandle "DirectoryPlugin block recurring: $subfile\n" if ($verbosity > 2);
307
308 #$count += &plugin::file_block_read ($pluginfo, $this_file_base_dir,
309 &plugin::file_block_read ($pluginfo, $this_file_base_dir,
310 &util::filename_cat($file, $subfile),
311 $block_hash, $metadata, $gli);
312
313 }
314 $self->sort_out_associated_files($block_hash);
315 #return $count;
316
317}
[17738]318
319# We don't do metadata_read
320sub metadata_read {
321 my $self = shift (@_);
[19493]322 my ($pluginfo, $base_dir, $file, $block_hash,
323 $extrametakeys, $extrametadata, $extrametafile,
324 $processor, $maxdocs, $gli) = @_;
[17738]325
326 return undef;
327}
328
329
[16391]330# return number of files processed, undef if can't process
331# Note that $base_dir might be "" and that $file might
332# include directories
333
334# This function passes around metadata hash structures. Metadata hash
335# structures are hashes that map from a (scalar) key (the metadata element
336# name) to either a scalar metadata value or a reference to an array of
337# such values.
338
339sub read {
340 my $self = shift (@_);
341 my ($pluginfo, $base_dir, $file, $block_hash, $in_metadata, $processor, $maxdocs, $total_count, $gli) = @_;
[17320]342
[16391]343 my $outhandle = $self->{'outhandle'};
344 my $verbosity = $self->{'verbosity'};
345
346 # Calculate the directory name and ensure it is a directory and
347 # that it is not explicitly blocked.
348 my $dirname;
349 if ($file eq "") {
350 $dirname = $base_dir;
351 } else {
352 $dirname = $file;
353 $dirname = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/;
354 }
355
356 my $directory_ok = $self->check_directory_path($dirname);
357 return $directory_ok unless (defined $directory_ok && $directory_ok == 1);
358
[2228]359 if (($verbosity > 2) && ((scalar keys %$in_metadata) > 0)) {
[15870]360 print $outhandle "DirectoryPlugin: metadata passed in: ",
[2813]361 join(", ", keys %$in_metadata), "\n";
[2228]362 }
[2813]363
[16391]364
[2228]365 # Recur over directory contents.
366 my (@dir, $subfile);
367 my $count = 0;
[6332]368
[16391]369 print $outhandle "DirectoryPlugin read: getting directory $dirname\n" if ($verbosity > 2);
[2813]370
[2228]371 # find all the files in the directory
372 if (!opendir (DIR, $dirname)) {
[9584]373 if ($gli) {
374 print STDERR "<ProcessingError n='$file' r='Could not read directory $dirname'>\n";
375 }
[15870]376 print $outhandle "DirectoryPlugin: WARNING - couldn't read directory $dirname\n";
[7362]377 return -1; # error in processing
[2228]378 }
379 @dir = readdir (DIR);
380 closedir (DIR);
[7686]381
382 # Re-order the files in the list so any directories ending with .all are moved to the end
[8716]383 for (my $i = scalar(@dir) - 1; $i >= 0; $i--) {
[7688]384 if (-d &util::filename_cat($dirname, $dir[$i]) && $dir[$i] =~ /\.all$/) {
[7686]385 push(@dir, splice(@dir, $i, 1));
386 }
387 }
388
[13188]389 # setup the metadata structures. we do a metadata_read pass to see if there is any additional metadata, then pass it to read
390
[2228]391 my $additionalmetadata = 0; # is there extra metadata available?
392 my %extrametadata; # maps from filespec to extra metadata keys
[19493]393 my %extrametafile; # maps from filespec to the metadata.xml (or similar) file it came from
[2228]394 my @extrametakeys; # keys of %extrametadata in order read
[8512]395
[16391]396
[11919]397 my $os_dirsep = &util::get_os_dirsep();
[8737]398 my $dirsep = &util::get_dirsep();
[11919]399 my $base_dir_regexp = $base_dir;
400 $base_dir_regexp =~ s/\//$os_dirsep/g;
[8737]401 my $local_dirname = $dirname;
[11919]402 $local_dirname =~ s/^$base_dir_regexp($os_dirsep)//;
[8737]403 $local_dirname .= $dirsep;
[19623]404
[8737]405 if (defined $self->{'subdir_extrametakeys'}->{$local_dirname}) {
406 my $extrakeys = $self->{'subdir_extrametakeys'}->{$local_dirname};
407 foreach my $ek (@$extrakeys) {
408 my $extrakeys_re = $ek->{'re'};
409 my $extrakeys_md = $ek->{'md'};
[19493]410 my $extrakeys_mf = $ek->{'mf'};
[8737]411 push(@extrametakeys,$extrakeys_re);
412 $extrametadata{$extrakeys_re} = $extrakeys_md;
[19493]413 $extrametafile{$extrakeys_re} = $extrakeys_mf;
[8737]414 }
415 delete($self->{'subdir_extrametakeys'}->{$local_dirname});
416 }
[8512]417
[9145]418 # apply metadata pass for each of the files in the directory
[7686]419 my $num_files = scalar(@dir);
[8512]420 for (my $i = 0; $i < scalar(@dir); $i++) {
421 my $subfile = $dir[$i];
422 my $this_file_base_dir = $base_dir;
423 last if ($maxdocs != -1 && $count >= $maxdocs);
[9145]424 next if ($subfile =~ m/^\.\.?$/);
[16391]425 my $file_subfile = &util::filename_cat($file, $subfile);
426 my $full_filename = &util::filename_cat($this_file_base_dir, $file_subfile);
427 if ($self->file_is_blocked($block_hash,$full_filename)) {
428 print STDERR "DirectoryPlugin: file $full_filename was blocked for metadata_read\n" if ($verbosity > 2);
429 next;
430 }
431
[8512]432 # Recursively read each $subfile
[15870]433 print $outhandle "DirectoryPlugin metadata recurring: $subfile\n" if ($verbosity > 2);
[8512]434
435 $count += &plugin::metadata_read ($pluginfo, $this_file_base_dir,
[16391]436 $file_subfile,$block_hash,
[17313]437 \@extrametakeys, \%extrametadata,
[19493]438 \%extrametafile,
[8512]439 $processor, $maxdocs, $gli);
440 $additionalmetadata = 1;
441 }
[16391]442
[8737]443 # filter out any extrametakeys that mention subdirectories and store
444 # for later use (i.e. when that sub-directory is being processed)
445
446 foreach my $ek (@extrametakeys) {
447 my ($subdir_re,$extrakey_dir) = &File::Basename::fileparse($ek);
[19623]448
449 $extrakey_dir =~ s/\\\./\./g; # remove RE syntax for .
450 $extrakey_dir =~ s/\\\\/\\/g; # remove RE syntax for \
[8737]451
[9122]452 my $dirsep_re = &util::get_re_dirsep();
[15005]453
454 my $ek_non_re = $ek;
[19623]455 $ek_non_re =~ s/\\\./\./g; # remove RE syntax for .
456 $ek_non_re =~ s/\\\\/\\/g; # remove RE syntax for \
[15005]457 if ($ek_non_re =~ m/$dirsep_re/) { # specifies at least one directory
[8737]458 my $md = $extrametadata{$ek};
[19493]459 my $mf = $extrametafile{$ek};
[8737]460
461 my $subdir_extrametakeys = $self->{'subdir_extrametakeys'};
462
[19493]463 my $subdir_rec = { 're' => $subdir_re, 'md' => $md, 'mf' => $mf };
[15005]464
[17320]465 # when its looked up, it must be relative to the base dir
466 push(@{$subdir_extrametakeys->{"$local_dirname$extrakey_dir"}},$subdir_rec);
467 #push(@{$subdir_extrametakeys->{"$extrakey_dir"}},$subdir_rec);
[8737]468 }
469 }
[8512]470
471 # import each of the files in the directory
472 $count=0;
[7686]473 for (my $i = 0; $i <= scalar(@dir); $i++) {
474 # When every file in the directory has been done, pause for a moment (figuratively!)
475 # If the -recheck_directories argument hasn't been provided, stop now (default)
476 # Otherwise, re-read the contents of the directory to check for new files
477 # Any new files are added to the @dir list and are processed as normal
478 # This is necessary when documents to be indexed are specified in bibliographic DBs
479 # These files are copied/downloaded and stored in a new folder at import time
480 if ($i == $num_files) {
481 last unless $self->{'recheck_directories'};
482
483 # Re-read the files in the directory to see if there are any new files
484 last if (!opendir (DIR, $dirname));
485 my @dirnow = readdir (DIR);
486 closedir (DIR);
487
488 # We're only interested if there are more files than there were before
489 last if (scalar(@dirnow) <= scalar(@dir));
490
491 # Any new files are added to the end of @dir to get processed by the loop
[8716]492 my $j;
[7686]493 foreach my $subfilenow (@dirnow) {
494 for ($j = 0; $j < $num_files; $j++) {
495 last if ($subfilenow eq $dir[$j]);
496 }
497 if ($j == $num_files) {
498 # New file
499 push(@dir, $subfilenow);
500 }
501 }
502 # When the new files have been processed, check again
503 $num_files = scalar(@dir);
504 }
505
506 my $subfile = $dir[$i];
[7932]507 my $this_file_base_dir = $base_dir;
[9853]508 last if ($maxdocs != -1 && ($count + $total_count) >= $maxdocs);
[2228]509 next if ($subfile =~ /^\.\.?$/);
[3108]510
[16391]511 my $file_subfile = &util::filename_cat($file, $subfile);
512 my $full_filename
513 = &util::filename_cat($this_file_base_dir,$file_subfile);
514
515 if ($self->file_is_blocked($block_hash,$full_filename)) {
516 print STDERR "DirectoryPlugin: file $full_filename was blocked for read\n" if ($verbosity > 2);
517 next;
518 }
[17313]519 #print STDERR "processing $full_filename\n";
[7932]520 # Follow Windows shortcuts
521 if ($subfile =~ /(?i)\.lnk$/ && $ENV{'GSDLOS'} =~ /^windows$/i) {
522 require Win32::Shortcut;
523 my $shortcut = new Win32::Shortcut(&util::filename_cat($dirname, $subfile));
524 if ($shortcut) {
525 # The file to be processed is now the target of the shortcut
526 $this_file_base_dir = "";
527 $file = "";
528 $subfile = $shortcut->Path;
529 }
530 }
531
[3108]532 # check for a symlink pointing back to a leading directory
533 if (-d "$dirname/$subfile" && -l "$dirname/$subfile") {
534 # readlink gives a "fatal error" on systems that don't implement
535 # symlinks. This assumes the the -l test above would fail on those.
536 my $linkdest=readlink "$dirname/$subfile";
537 if (!defined ($linkdest)) {
538 # system error - file not found?
[15870]539 warn "DirectoryPlugin: symlink problem - $!";
[3108]540 } else {
541 # see if link points to current or a parent directory
542 if ($linkdest =~ m@^[\./\\]+$@ ||
543 index($dirname, $linkdest) != -1) {
[15870]544 warn "DirectoryPlugin: Ignoring recursive symlink ($dirname/$subfile -> $linkdest)\n";
[3108]545 next;
546 ;
547 }
548 }
549 }
550
[15870]551 print $outhandle "DirectoryPlugin: preparing metadata for $subfile\n" if ($verbosity > 2);
[317]552
[2228]553 # Make a copy of $in_metadata to pass to $subfile
[17313]554 my $out_metadata = {};
[13188]555 &metadatautil::combine_metadata_structures($out_metadata, $in_metadata);
[317]556
[16391]557 # check the assocfile_info
558 if (defined $self->{'assocfile_info'}->{$full_filename}) {
559 &metadatautil::combine_metadata_structures($out_metadata, $self->{'assocfile_info'}->{$full_filename});
560 }
[17313]561 ## encode the filename as perl5 doesn't handle unicode filenames
562
[13545]563 my $tmpfile = Encode::encode_utf8($subfile);
[17313]564 #print STDERR "subfile = $subfile, tmpfile = $tmpfile\n";
[2228]565 # Next add metadata read in XML files (if it is supplied)
566 if ($additionalmetadata == 1) {
[19493]567 foreach my $filespec (@extrametakeys) {
[19623]568
[17320]569 ## use the utf8 encoded filename to do the filename comparison
[13545]570 if ($tmpfile =~ /^$filespec$/) {
[2228]571 print $outhandle "File \"$subfile\" matches filespec \"$filespec\"\n"
572 if ($verbosity > 2);
[19493]573 my $mdref = $extrametadata{$filespec};
574 my $mfref = $extrametafile{$filespec};
575
576 # Add the list files where the metadata came from
577 # into the metadata table so we can track this
578 # This mechanism is similar to how gsdlassocfile works
579
580 my @metafile_pair = ();
581 foreach my $l (keys %$mfref) {
582 my $f = $mfref->{$l};
[19516]583 push (@metafile_pair, "$f : $l");
[19493]584 }
585
586 $mdref->{'gsdlmetafile'} = \@metafile_pair;
587
[13188]588 &metadatautil::combine_metadata_structures($out_metadata, $mdref);
[2228]589 }
[4]590 }
591 }
[10156]592
593 if (defined $self->{'inf_timestamp'}) {
[18469]594 # Look to see if it's a completely new file
[10156]595
[18469]596 if (!$block_hash->{'new_files'}->{$full_filename}) {
597 # Not a new file, must be an existing file
598 # Let' see if it's newer than the last import.pl
599
600
601 if (! -d $full_filename) {
[19493]602 if (!$block_hash->{'reindex_files'}->{$full_filename}) {
[20577]603 # filename has been around for longer than inf_timestamp
[18469]604 print $outhandle "**** Skipping $subfile\n" if ($verbosity >3);
605 next;
606 }
607 else {
608 # Remove old folder in archives (might hash to something different)
609 # *** should be doing this on a Del one as well
610 # but leave folder name?? and ensure hashs to
611 # same again??
612
613 # Then let through as new doc??
614
615 # mark to doc-oids that rely on it for re-indexing
616 ## &GDBMUtils::gdbmDatabase();
617 }
[10156]618 }
619 }
620 }
621
[2228]622 # Recursively read each $subfile
[15870]623 print $outhandle "DirectoryPlugin recurring: $subfile\n" if ($verbosity > 2);
[8512]624
625 $count += &plugin::read ($pluginfo, $this_file_base_dir,
[16391]626 $file_subfile, $block_hash,
[9853]627 $out_metadata, $processor, $maxdocs, ($total_count + $count), $gli);
[4]628 }
[7686]629
[8512]630 return $count;
[2228]631}
[4]632
[17738]633sub compile_stats {
634 my $self = shift(@_);
635 my ($stats) = @_;
636}
637
[4]6381;
Note: See TracBrowser for help on using the repository browser.