Changeset 7439


Ignore:
Timestamp:
05/16/10 16:15:31 (2 years ago)
Author:
GeorgeClark
Message:

Item9015: Some optimizations

  • Don't retrieve pub directory if automatic attachment of pub files is not enabled
  • Don't process the list of files if the number found is consistent with the number in Metadata

Also fix unit tests to work even if test environment has auto attach disabled.

Location:
trunk/AttachmentListPlugin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/AttachmentListPlugin/lib/Foswiki/Plugins/AttachmentListPlugin.pm

    r7396 r7439  
    164164    # has META:FILEATTACHMENT data 
    165165    my $attachments = _getAttachmentsInTopic( $inWeb, $inTopic ); 
    166     my $attach_files = _getAttachmentList( $inWeb, $inTopic ); 
     166    my $attach_files = _getAttachmentList( $inWeb, $inTopic ) if ($Foswiki::cfg{RCS}{AutoAttachPubFiles}) ; 
     167 
     168    #print STDERR "attachments = " . scalar @$attachments . "\n"; 
     169    #print STDERR "files = " . scalar @$attach_files . "\n" ; 
    167170 
    168171    _debug("AttachmentListPlugin::_createFileData"); 
     
    181184        } 
    182185 
    183         foreach my $fileName (@$attach_files) { 
    184             unless ($inTopicHash->{$inTopic}{$fileName}) { 
    185                 my $fd = 
    186                   Foswiki::Plugins::AttachmentListPlugin::FileData->new( $inWeb, 
    187                     $inTopic, { name => $fileName, path => $fileName, autoattached => 1}  ); 
    188                 $inTopicHash->{$inTopic}{$fileName} = \$fd; 
     186        if ($Foswiki::cfg{RCS}{AutoAttachPubFiles} && defined $attach_files && (scalar @$attachments != scalar @$attach_files)) { 
     187            foreach my $fileName (@$attach_files) { 
     188                unless ($inTopicHash->{$inTopic}{$fileName}) { 
     189                    my $fd = 
     190                      Foswiki::Plugins::AttachmentListPlugin::FileData->new( $inWeb, 
     191                        $inTopic, { name => $fileName, path => $fileName, autoattached => 1}  ); 
     192                    $inTopicHash->{$inTopic}{$fileName} = \$fd; 
     193                } 
    189194            } 
    190195        } 
     
    350355    my ($web, $topic) = @_; 
    351356 
     357    #print STDERR "getAttachmentList entered for $web $topic\n"; 
    352358    my $dir  = "$Foswiki::cfg{PubDir}/$web/$topic"; 
    353359    my $dh; 
  • trunk/AttachmentListPlugin/test/unit/AttachmentListPlugin/AttachmentListPluginTests.pm

    r7406 r7439  
    203203    my $testTopic1 = $testAttachments{topic1}{name}; 
    204204    my $testTopic2 = $testAttachments{topic2}{name}; 
     205    $Foswiki::cfg{RCS}{AutoAttachPubFiles} = 1; 
    205206 
    206207    my $source = 
Note: See TracChangeset for help on using the changeset viewer.