Index: /main/trunk/greenstone2/perllib/inexport.pm
===================================================================
--- /main/trunk/greenstone2/perllib/inexport.pm	(revision 32847)
+++ /main/trunk/greenstone2/perllib/inexport.pm	(revision 32848)
@@ -66,120 +66,120 @@
 
 $inexport::directory_arguments = 
-[
-      { 'name' => "importdir",
-	'desc' => "{import.importdir}",
-	'type' => "string",
-	'reqd' => "no",
-	'deft' => "import",
-        'hiddengli' => "yes" },
-      { 'name' => "collectdir",
-	'desc' => "{import.collectdir}",
-	'type' => "string",
-	# parsearg left "" as default
-	#'deft' => &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect"),
-	'deft' => "",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
- 
-];
+    [
+     { 'name' => "importdir",
+       'desc' => "{import.importdir}",
+       'type' => "string",
+       'reqd' => "no",
+       'deft' => "import",
+       'hiddengli' => "yes" },
+     { 'name' => "collectdir",
+       'desc' => "{import.collectdir}",
+       'type' => "string",
+       # parsearg left "" as default
+       #'deft' => &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect"),
+       'deft' => "",
+       'reqd' => "no",
+       'hiddengli' => "yes" },
+     
+    ];
 $inexport::arguments = 
-[
-      # don't set the default to hash - want to allow this to come from
-      # entry in collect.cfg but want to override it here 
-      { 'name' => "OIDtype",
-	'desc' => "{import.OIDtype}",
-	'type' => "enum",
-	'list' => $oidtype_list,
-	'deft' => "hash_on_full_filename",
-	'reqd' => "no",
-	'modegli' => "2" },
-      { 'name' => "OIDmetadata",
-	'desc' => "{import.OIDmetadata}",
-	'type' => "string",
-	'deft' => "dc.Identifier",
-	'reqd' => "no",
-	'modegli' => "2" },
-      { 'name' => "site",
-	'desc' => "{import.site}",
-	'type' => "string",
-	'deft' => "",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
-      { 'name' => "manifest",
-	'desc' => "{import.manifest}",
-	'type' => "string",
-	'deft' => "",
-	'reqd' => "no",
-        'hiddengli' => "yes" } ,
+    [
+     # don't set the default to hash - want to allow this to come from
+     # entry in collect.cfg but want to override it here 
+     { 'name' => "OIDtype",
+       'desc' => "{import.OIDtype}",
+       'type' => "enum",
+       'list' => $oidtype_list,
+       'deft' => "hash_on_full_filename",
+       'reqd' => "no",
+       'modegli' => "2" },
+     { 'name' => "OIDmetadata",
+       'desc' => "{import.OIDmetadata}",
+       'type' => "string",
+       'deft' => "dc.Identifier",
+       'reqd' => "no",
+       'modegli' => "2" },
+     { 'name' => "site",
+       'desc' => "{import.site}",
+       'type' => "string",
+       'deft' => "",
+       'reqd' => "no",
+       'hiddengli' => "yes" },
+     { 'name' => "manifest",
+       'desc' => "{import.manifest}",
+       'type' => "string",
+       'deft' => "",
+       'reqd' => "no",
+       'hiddengli' => "yes" } ,
      { 'name' => "incremental",
-	'desc' => "{import.incremental}",
-	'type' => "flag",
-	'hiddengli' => "yes" },
-      { 'name' => "keepold",
-	'desc' => "{import.keepold}",
-	'type' => "flag",
-	'reqd' => "no",
-	'hiddengli' => "yes" },
-      { 'name' => "removeold",
-	'desc' => "{import.removeold}",
-	'type' => "flag",
-	'reqd' => "no",
-	'hiddengli' => "yes" },
-      { 'name' => "language",
-	'desc' => "{scripts.language}",
-	'type' => "string",
-	'reqd' => "no",
-	'hiddengli' => "yes" },
-      { 'name' => "maxdocs",
-	'desc' => "{import.maxdocs}",
-	'type' => "int",
-	'reqd' => "no",
-	'deft' => "-1",
-	'range' => "-1,",
-	'modegli' => "1" },
-       { 'name' => "debug",
-	'desc' => "{import.debug}",
-	'type' => "flag",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
-      { 'name' => "faillog",
-	'desc' => "{import.faillog}",
-	'type' => "string",
-	# parsearg left "" as default
-	#'deft' => &FileUtils::filenameConcatenate("&lt;collectdir&gt;", "colname", "etc", "fail.log"),
-	'deft' => "",
-	'reqd' => "no",
-        'modegli' => "3" },
-       { 'name' => "out",
-	'desc' => "{import.out}",
-	'type' => "string",
-	'deft' => "STDERR",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
-      { 'name' => "statsfile",
-	'desc' => "{import.statsfile}",
-	'type' => "string",
-	'deft' => "STDERR",
-	'reqd' => "no",
-        'hiddengli' => "yes" },
-      { 'name' => "verbosity",
-	'desc' => "{import.verbosity}",
-	'type' => "int",
-	'range' => "0,",
-	'deft' => "2",
-	'reqd' => "no",
-	'modegli' => "3" },
-      { 'name' => "gli",
-	'desc' => "{scripts.gli}",
-	'type' => "flag",
-	'reqd' => "no",
-	'hiddengli' => "yes" },
-      { 'name' => "xml",
-	'desc' => "{scripts.xml}",
-	'type' => "flag",
-	'reqd' => "no",
-	'hiddengli' => "yes" },
-
-];
+       'desc' => "{import.incremental}",
+       'type' => "flag",
+       'hiddengli' => "yes" },
+     { 'name' => "keepold",
+       'desc' => "{import.keepold}",
+       'type' => "flag",
+       'reqd' => "no",
+       'hiddengli' => "yes" },
+     { 'name' => "removeold",
+       'desc' => "{import.removeold}",
+       'type' => "flag",
+       'reqd' => "no",
+       'hiddengli' => "yes" },
+     { 'name' => "language",
+       'desc' => "{scripts.language}",
+       'type' => "string",
+       'reqd' => "no",
+       'hiddengli' => "yes" },
+     { 'name' => "maxdocs",
+       'desc' => "{import.maxdocs}",
+       'type' => "int",
+       'reqd' => "no",
+       'deft' => "-1",
+       'range' => "-1,",
+       'modegli' => "1" },
+     { 'name' => "debug",
+       'desc' => "{import.debug}",
+       'type' => "flag",
+       'reqd' => "no",
+       'hiddengli' => "yes" },
+     { 'name' => "faillog",
+       'desc' => "{import.faillog}",
+       'type' => "string",
+       # parsearg left "" as default
+       #'deft' => &FileUtils::filenameConcatenate("&lt;collectdir&gt;", "colname", "etc", "fail.log"),
+       'deft' => "",
+       'reqd' => "no",
+       'modegli' => "3" },
+     { 'name' => "out",
+       'desc' => "{import.out}",
+       'type' => "string",
+       'deft' => "STDERR",
+       'reqd' => "no",
+       'hiddengli' => "yes" },
+     { 'name' => "statsfile",
+       'desc' => "{import.statsfile}",
+       'type' => "string",
+       'deft' => "STDERR",
+       'reqd' => "no",
+       'hiddengli' => "yes" },
+     { 'name' => "verbosity",
+       'desc' => "{import.verbosity}",
+       'type' => "int",
+       'range' => "0,",
+       'deft' => "2",
+       'reqd' => "no",
+       'modegli' => "3" },
+     { 'name' => "gli",
+       'desc' => "{scripts.gli}",
+       'type' => "flag",
+       'reqd' => "no",
+       'hiddengli' => "yes" },
+     { 'name' => "xml",
+       'desc' => "{scripts.xml}",
+       'type' => "flag",
+       'reqd' => "no",
+       'hiddengli' => "yes" },
+
+    ];
 
 sub new 
@@ -288,15 +288,15 @@
     $self->{'out'} = STDERR;
     
-	if (defined $gsdl_cgi) {
-		$self->{'site'} = $opt_site;
-		my $collect_dir = $gsdl_cgi->get_collection_dir($opt_site);
-		$self->{'collectdir'} = $collect_dir;
-	}
-	else {	
-		$self->{'site'} = "";
-		$self->{'collectdir'} = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"collect");
-	}
+    if (defined $gsdl_cgi) {
+	$self->{'site'} = $opt_site;
+	my $collect_dir = $gsdl_cgi->get_collection_dir($opt_site);
+	$self->{'collectdir'} = $collect_dir;
+    }
+    else {	
+	$self->{'site'} = "";
+	$self->{'collectdir'} = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"collect");
+    }
     $self->{'faillog'} = "";
-   
+    
     $self->{'collection'} = $collect;
 
@@ -319,5 +319,5 @@
     my $site       = $self->{'site'};
     my $out        = $self->{'out'};
-	 
+    
     if (($collection = &colcfg::use_collection($site, $collection, $collectdir)) eq "") {
 	#&PrintUsage::print_txt_usage($options, "{import.params}", 1);
@@ -378,5 +378,5 @@
     if (!defined($collectcfg->{'infodbtype'}))
     {
-      $collectcfg->{'infodbtype'} = &dbutil::get_default_infodb_type();
+	$collectcfg->{'infodbtype'} = &dbutil::get_default_infodb_type();
     }
     if ($collectcfg->{'infodbtype'} eq "gdbm-txtgz") {
@@ -403,19 +403,19 @@
     if (!&FileUtils::isFilenameAbsolute($importdir))
     {
-      $importdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, $importdir);
+	$importdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, $importdir);
     }
     else
     {
-      # Don't do this - it kills protocol prefixes
-      #$importdir =~ s/[\\\/]+/\//g;
-      #$importdir =~ s/\/$//;
-      # Do this instead
-      &FileUtils::sanitizePath($importdir);
+	# Don't do this - it kills protocol prefixes
+	#$importdir =~ s/[\\\/]+/\//g;
+	#$importdir =~ s/\/$//;
+	# Do this instead
+	&FileUtils::sanitizePath($importdir);
     }
 
     if (!&FileUtils::directoryExists($importdir))
     {
-      &gsprintf($out, "{import.no_import_dir}\n\n", $importdir);
-      die "\n";
+	&gsprintf($out, "{import.no_import_dir}\n\n", $importdir);
+	die "\n";
     }
     $self->{'importdir'} = $importdir;
@@ -435,5 +435,5 @@
 	} 
     }
- 
+    
     if (defined $collectcfg->{'manifest'} && $self->{'manifest'} eq "") {
 	$self->{'manifest'} = $collectcfg->{'manifest'};
@@ -452,5 +452,5 @@
     }
 
-   
+    
 
     if (defined $self->{'default_OIDtype'} ) {
@@ -474,5 +474,5 @@
     }
     $self->{'gli'} = 0 unless defined $self->{'gli'};
-       
+    
     # check keepold and removeold
     my $checkdir = ($inexport_mode eq "import") ? "archives" : "export";
@@ -492,7 +492,7 @@
     if ($self->{'manifest'} && (!$keepold || !$incremental))
     {
-      print STDERR "Warning: -manifest flag should not be specified without also setting -keepold or -incremental\n";
-    }
-	}
+	print STDERR "Warning: -manifest flag should not be specified without also setting -keepold or -incremental\n";
+    }
+}
 
 sub process_files
@@ -727,9 +727,9 @@
     if ($manifest eq '' || (defined $collectcfg->{'complexmeta'} && $collectcfg->{'complexmeta'} eq 'true'))
     {
-      &plugin::file_block_read($pluginfo, $importdir, "", $block_hash, $metadata, $gli);
+	&plugin::file_block_read($pluginfo, $importdir, "", $block_hash, $metadata, $gli);
     }
     else
     {
-      print STDERR "Skipping global file scan due to manifest and complexmeta configuration\n";
+	print STDERR "Skipping global file scan due to manifest and complexmeta configuration\n";
     }
 
@@ -744,7 +744,7 @@
     if ($manifest ne "") {
 
-      # mark that we are using a manifest - information that might be needed
-      # down in plugins (for instance DirectoryPlugin)
-      $block_hash->{'manifest'} = $self->{'manifest_version'};
+	# mark that we are using a manifest - information that might be needed
+	# down in plugins (for instance DirectoryPlugin)
+	$block_hash->{'manifest'} = $self->{'manifest_version'};
 
 	# 
@@ -826,68 +826,68 @@
 
 	my $arcinfo_src_filename = &dbutil::get_infodb_file_path($collectcfg->{'infodbtype'}, "archiveinf-src", $archivedir);
-      # need to check this file exists before trying to read it - in the past
-      # it wasn't possible to have a manifest unless keepold was also set so
-      # you were pretty much guaranteed arcinfo existed
-      # [jmt12]
-      # @todo &FileUtils::fileExists($arcinfo_src_filename) [jmt12]
-      if (-e $arcinfo_src_filename)
-      {
-	my $arcinfodb_map = {};
-	&dbutil::read_infodb_file($collectcfg->{'infodbtype'}, $arcinfo_src_filename, $arcinfodb_map);
-	foreach my $f (@full_new_files) {
-	    my $rel_f = &util::abspath_to_placeholders($f);
-
-	    # check that we haven't seen it already
-	    if (defined $arcinfodb_map->{$rel_f}) {
-		# TODO make better warning
-		print STDERR "Warning: $f ($rel_f) already in src archive, \n";
-	    } else {
+	# need to check this file exists before trying to read it - in the past
+	# it wasn't possible to have a manifest unless keepold was also set so
+	# you were pretty much guaranteed arcinfo existed
+	# [jmt12]
+	# @todo &FileUtils::fileExists($arcinfo_src_filename) [jmt12]
+	if (-e $arcinfo_src_filename)
+	{
+	    my $arcinfodb_map = {};
+	    &dbutil::read_infodb_file($collectcfg->{'infodbtype'}, $arcinfo_src_filename, $arcinfodb_map);
+	    foreach my $f (@full_new_files) {
+		my $rel_f = &util::abspath_to_placeholders($f);
+
+		# check that we haven't seen it already
+		if (defined $arcinfodb_map->{$rel_f}) {
+		    # TODO make better warning
+		    print STDERR "Warning: $f ($rel_f) already in src archive, \n";
+		} else {
+		    $block_hash->{'new_files'}->{$f} = 1;
+		}
+	    }
+
+	    undef $arcinfodb_map;
+	}
+	# no existing files - so we can just add all the files [jmt12]
+	else
+	{
+	    foreach my $f (@full_new_files)
+	    {
 		$block_hash->{'new_files'}->{$f} = 1;
 	    }
 	}
-
-	undef $arcinfodb_map;
-      }
-      # no existing files - so we can just add all the files [jmt12]
-      else
-      {
-        foreach my $f (@full_new_files)
-        {
-          $block_hash->{'new_files'}->{$f} = 1;
-        }
-      }
-    
-      # If we are not using complex inherited metadata (and thus have skipped
-      # the global file scan) we need to at least check for a matching
-      # metadata.xml for the files being indexed/reindexed
-      # - unless we are using the newer version of Manifests, which are treated
-      #   verbatim, and should have a metadata element for metadata files (so
-      #   we can explicitly process metadata files other than metadata.xml)
-      # [jmt12]
-      if ($self->{'manifest_version'} == 1 && (!defined $collectcfg->{'complexmeta'} || $collectcfg->{'complexmeta'} ne 'true'))
-      {
-        my @all_files_to_import = (keys %{$block_hash->{'reindex_files'}}, keys %{$block_hash->{'new_files'}});
-        foreach my $file_to_import (@all_files_to_import)
-        {
-          my $metadata_xml_path = $file_to_import;
-          $metadata_xml_path =~ s/[^\\\/]*$/metadata.xml/;
-          if (&FileUtils::fileExists($metadata_xml_path))
-          {
-            &plugin::file_block_read($pluginfo, '', $metadata_xml_path, $block_hash, $metadata, $gli);
-          }
-        }
-      }
-
-      # new version manifest files explicitly list metadata files to be
-      # processed (ignoring complexmeta if set)
-      # [jmt12]
-      if ($self->{'manifest_version'} > 1)
-      {
-        # Process metadata files
-        foreach my $file_to_import (keys %{$block_hash->{'reindex_files'}}, keys %{$block_hash->{'new_files'}})
-        {
-          $self->perform_process_files($manifest, $pluginfo, '', $file_to_import, $block_hash, $metadata, $processor, $maxdocs);
-        }
-      }
+	
+	# If we are not using complex inherited metadata (and thus have skipped
+	# the global file scan) we need to at least check for a matching
+	# metadata.xml for the files being indexed/reindexed
+	# - unless we are using the newer version of Manifests, which are treated
+	#   verbatim, and should have a metadata element for metadata files (so
+	#   we can explicitly process metadata files other than metadata.xml)
+	# [jmt12]
+	if ($self->{'manifest_version'} == 1 && (!defined $collectcfg->{'complexmeta'} || $collectcfg->{'complexmeta'} ne 'true'))
+	{
+	    my @all_files_to_import = (keys %{$block_hash->{'reindex_files'}}, keys %{$block_hash->{'new_files'}});
+	    foreach my $file_to_import (@all_files_to_import)
+	    {
+		my $metadata_xml_path = $file_to_import;
+		$metadata_xml_path =~ s/[^\\\/]*$/metadata.xml/;
+		if (&FileUtils::fileExists($metadata_xml_path))
+		{
+		    &plugin::file_block_read($pluginfo, '', $metadata_xml_path, $block_hash, $metadata, $gli);
+		}
+	    }
+	}
+
+	# new version manifest files explicitly list metadata files to be
+	# processed (ignoring complexmeta if set)
+	# [jmt12]
+	if ($self->{'manifest_version'} > 1)
+	{
+	    # Process metadata files
+	    foreach my $file_to_import (keys %{$block_hash->{'reindex_files'}}, keys %{$block_hash->{'new_files'}})
+	    {
+		$self->perform_process_files($manifest, $pluginfo, '', $file_to_import, $block_hash, $metadata, $processor, $maxdocs);
+	    }
+	}
     } # end if (manifest ne "")
     else {
@@ -910,5 +910,5 @@
 
 	    if ($incremental) {
-               # only look for deletions if we are truely incremental
+		# only look for deletions if we are truely incremental
 		my @deleted_files = sort keys %{$block_hash->{'deleted_files'}};
 		# Filter out any in gsdl/tmp area
@@ -918,5 +918,5 @@
 		$gsdl_tmp_area = &util::filename_to_regex($gsdl_tmp_area);
 		$collect_tmp_area = &util::filename_to_regex($collect_tmp_area);
-			      
+		
 		foreach my $df (@deleted_files) {
 		    next if ($df =~ m/^$gsdl_tmp_area/);
@@ -932,6 +932,6 @@
 		    print STDERR "Files deleted since last import:\n  ";
 		    print STDERR join("\n  ",@deleted_files), "\n";
-		
-		
+		    
+		    
 		    &plugin::remove_some($pluginfo, $collectcfg->{'infodbtype'}, $archivedir, \@deleted_files);
 		    
@@ -947,5 +947,5 @@
 		    mark_docs_for_deletion($archive_info,$block_hash,\@reindex_files, $archivedir,$verbosity, "reindex");
 		}
-				
+		
 	    }	    
 	} # end if incremental/only_add mode
@@ -961,17 +961,17 @@
     my $earliestDatestampFile = &FileUtils::filenameConcatenate($archivedir, "earliestDatestamp");
     if ($self->{'generate_auxiliary_files'}) {
-    if (!-f $earliestDatestampFile && -d $archivedir) {
-	my $current_time_in_seconds = time; # in seconds
-
-	if(open(FOUT, ">$earliestDatestampFile")) {
-	    # || (&gsprintf(STDERR, "{common.cannot_open}: $!\n", $earliestDatestampFile) && die);
-	    print FOUT $current_time_in_seconds;
-	    close(FOUT);
-	}
-	else {
-	    &gsprintf(STDERR, "{import.cannot_write_earliestdatestamp}\n", $earliestDatestampFile);
-	}
-
-    }
+	if (!-f $earliestDatestampFile && -d $archivedir) {
+	    my $current_time_in_seconds = time; # in seconds
+
+	    if(open(FOUT, ">$earliestDatestampFile")) {
+		# || (&gsprintf(STDERR, "{common.cannot_open}: $!\n", $earliestDatestampFile) && die);
+		print FOUT $current_time_in_seconds;
+		close(FOUT);
+	    }
+	    else {
+		&gsprintf(STDERR, "{import.cannot_write_earliestdatestamp}\n", $earliestDatestampFile);
+	    }
+
+	}
     }
     
@@ -1004,5 +1004,5 @@
     if ($self->{'OIDtype'} eq 'incremental')
     {
-      store_doc_oid_count($archivedir);
+	store_doc_oid_count($archivedir);
     }
 
@@ -1011,5 +1011,5 @@
     $processor->end();
     
-#    if ($inexport_mode eq "import") {
+    #    if ($inexport_mode eq "import") {
     if ($self->{'generate_auxiliary_files'}) {
 	# write out the archive information file
@@ -1033,24 +1033,24 @@
 sub perform_process_files
 {
-  my $self = shift(@_);
-  my ($manifest, $pluginfo, $importdir, $file_to_import, $block_hash, $metadata, $processor, $maxdocs) = @_;
-  my $gli = $self->{'gli'};
-  # specific file to process - via manifest version 2+
-  if ($file_to_import ne '')
-  {
-    &plugin::read ($pluginfo, '', $file_to_import, $block_hash, $metadata, $processor, $maxdocs, 0, $gli);
-  }
-  # global file scan - if we are using a new version manifest, files would have
-  # been read above. Older manifests use extra settings in the $block_hash to
-  # control what is imported, while non-manifest imports use a regular
-  # $block_hash (so obeying process_exp and block_exp) [jmt12]
-  elsif ($manifest eq '' || $self->{'manifest_version'} == 1)
-  {
-    &plugin::read ($pluginfo, $importdir, '', $block_hash, $metadata, $processor, $maxdocs, 0, $gli);
-  }
-  else
-  {
-    print STDERR "Skipping perform_process_files() due to manifest presence and version\n";
-  }
+    my $self = shift(@_);
+    my ($manifest, $pluginfo, $importdir, $file_to_import, $block_hash, $metadata, $processor, $maxdocs) = @_;
+    my $gli = $self->{'gli'};
+    # specific file to process - via manifest version 2+
+    if ($file_to_import ne '')
+    {
+	&plugin::read ($pluginfo, '', $file_to_import, $block_hash, $metadata, $processor, $maxdocs, 0, $gli);
+    }
+    # global file scan - if we are using a new version manifest, files would have
+    # been read above. Older manifests use extra settings in the $block_hash to
+    # control what is imported, while non-manifest imports use a regular
+    # $block_hash (so obeying process_exp and block_exp) [jmt12]
+    elsif ($manifest eq '' || $self->{'manifest_version'} == 1)
+    {
+	&plugin::read ($pluginfo, $importdir, '', $block_hash, $metadata, $processor, $maxdocs, 0, $gli);
+    }
+    else
+    {
+	print STDERR "Skipping perform_process_files() due to manifest presence and version\n";
+    }
 }
 # perform_process_files()
@@ -1059,19 +1059,19 @@
 sub generate_statistics
 {
-  my $self = shift @_;
-  my ($pluginfo) = @_;
-
-  my $inexport_mode = $self->{'mode'};
-  my $out           = $self->{'out'};
-  my $faillogname   = $self->{'faillogname'};
-  my $statsfile     = $self->{'statsfile'};
-  my $gli           = $self->{'gli'};
-
-  &gsprintf($out, "\n");
-  &gsprintf($out, "*********************************************\n");
-  &gsprintf($out, "{$inexport_mode.complete}\n");
-  &gsprintf($out, "*********************************************\n");
-
-  &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli);
+    my $self = shift @_;
+    my ($pluginfo) = @_;
+
+    my $inexport_mode = $self->{'mode'};
+    my $out           = $self->{'out'};
+    my $faillogname   = $self->{'faillogname'};
+    my $statsfile     = $self->{'statsfile'};
+    my $gli           = $self->{'gli'};
+
+    &gsprintf($out, "\n");
+    &gsprintf($out, "*********************************************\n");
+    &gsprintf($out, "{$inexport_mode.complete}\n");
+    &gsprintf($out, "*********************************************\n");
+
+    &plugin::write_stats($pluginfo, $statsfile, $faillogname, $gli);
 }
 # generate_statistics()
@@ -1083,8 +1083,8 @@
 sub deinit
 {
-  my $self = shift(@_);
-  close OUT if $self->{'close_out'};
-  close FAILLOG if $self->{'close_faillog'};
-  close STATSFILE if $self->{'close_statsfile'};
+    my $self = shift(@_);
+    close OUT if $self->{'close_out'};
+    close FAILLOG if $self->{'close_faillog'};
+    close STATSFILE if $self->{'close_statsfile'};
 }
 # deinit()
@@ -1167,5 +1167,5 @@
     if (open(OIDOUT,">$oid_count_filename")) {
 	print OIDOUT $doc::OIDcount, "\n";
-	    
+	
 	close(OIDOUT);
     }
@@ -1197,5 +1197,5 @@
 
     foreach my $prev_file (keys %$prev_all_files) {
-		# arcinfo deals in real filenames ie windows short names. but the block hash stuff is all full long versions.
+	# arcinfo deals in real filenames ie windows short names. but the block hash stuff is all full long versions.
 	$prev_file = &util::upgrade_if_dos_filename($prev_file);
 	
@@ -1214,5 +1214,5 @@
     # there any more => mark them for deletion
     foreach my $curr_file (keys %{$block_hash->{'all_files'}}) {
-	  
+	
 	my $full_curr_file = $curr_file;
 
@@ -1299,8 +1299,8 @@
 
 	foreach my $existing_f (keys %{$block_hash->{'existing_files'}}) {
-	
+	    
 	    if ($existing_f =~ m/^$situated_dir/) {
 
-#		print STDERR "**** Existing file $existing_f\nis located within\n$situated_dir\n";
+		#		print STDERR "**** Existing file $existing_f\nis located within\n$situated_dir\n";
 
 		push(@$reindex_files,$existing_f);
@@ -1367,8 +1367,8 @@
 
 	  if (!-e $full_curr_file) {
-			$curr_file = &util::upgrade_if_dos_filename($curr_file);
+	      $curr_file = &util::upgrade_if_dos_filename($curr_file);
 	      $block_hash->{'deleted_files'}->{$curr_file} = 1;
 	  }
-      } @deleted_files;
+    } @deleted_files;
 
 
@@ -1404,5 +1404,5 @@
 	$archive_info->remove_reverseinfo($downgraded_file);
 	
-    foreach my $oid (@$oids) {
+	foreach my $oid (@$oids) {
 	    # get the record for this OID from doc db
 	    my $doc_rec = &dbutil::read_infodb_entry($infodbtype, $arcinfo_doc_filename, $oid);
@@ -1430,6 +1430,6 @@
 		    if (!defined $archive_info->get_reverseinfo($assocfile)) {
 			# nothing refers to it anymore, mark for reindex.
-				# block hash needs full filenames
-				$assocfile =  &util::upgrade_if_dos_filename($assocfile);
+			# block hash needs full filenames
+			$assocfile =  &util::upgrade_if_dos_filename($assocfile);
 			$block_hash->{'reindex_files'}->{$assocfile} = 1;
 		    }
@@ -1476,5 +1476,5 @@
 
     my ($dirname, $list) = @_;
- 
+    
     # Recur over directory contents.
     my (@dir, $subfile);
@@ -1499,7 +1499,7 @@
 	}
     }
-	
+    
 }
 
-    
+
 1;
