Skip to content

Commit

Permalink
Item1103: fix attachments and port to FSA response obj
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/GetAWebPlugin@2543 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Feb 20, 2009
1 parent 0afc0ed commit c08fbf9
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions lib/Foswiki/Plugins/GetAWebPlugin.pm
Expand Up @@ -20,6 +20,8 @@ use strict;
require Foswiki::Func; # The plugins API
require Foswiki::Plugins; # For the API version
use Archive::Tar;
use Error qw(:try);


use vars qw( $VERSION $RELEASE $SHORTDESCRIPTION $debug $pluginName $NO_PREFS_IN_TOPIC );

Expand Down Expand Up @@ -86,30 +88,29 @@ sub getaweb {
my( $meta, $text ) = Foswiki::Func::readTopic($webName, $topicName);
my @attachments = $meta->find( 'FILEATTACHMENT' );
foreach my $a ( @attachments ) {
# try {
my $data = Foswiki::Func::readAttachment($webName, $topicName, $a->{name} );
$tar->add_data( "pub/$saveasweb/".$a->{name}, $data ); # or die ???
# } catch Foswiki::AccessControlException with {
# };
#TODO: ,v file
my $handler = $session->{store}->_getHandler($webName, $topicName, $a->{name});
$handler->init();
if (-e $handler->{rcsFile}) {
local( $/, *FH ) ;
open( FH, '<', $handler->{rcsFile} ) or die $!;
my $contents = <FH>;
$tar->add_data( "pub/$saveasweb/$topicName/".$a->{name}.",v", $contents ); # or die ???
}
next unless ($handler->storedDataExists());
try {
my $data = Foswiki::Func::readAttachment($webName, $topicName, $a->{name} );
$tar->add_data( "pub/$saveasweb/$topicName/".$a->{name}, $data ); # or die ???
#my $handler = $session->{store}->_getHandler($webName, $topicName, $a->{name});
$handler->init();
if (-e $handler->{rcsFile}) {
local( $/, *FH ) ;
open( FH, '<', $handler->{rcsFile} ) or die $!;
my $contents = <FH>;
$tar->add_data( "pub/$saveasweb/$topicName/".$a->{name}.",v", $contents ); # or die ???
}
} catch Foswiki::AccessControlException with {
};

}
}

# sets response header
print $query->header(-type=>$outputType, -expire=>'now');
my $io = IO::Handle->new() or die $!;
$io->fdopen(fileno(STDOUT), "w") or die $!;
$tar->write( $io ) or die $!;
$io->close();

$session->{response}->header(
-type => $outputType, -expire=>'now' );
$session->{response}->body($tar->write());

return;
}

Expand Down

0 comments on commit c08fbf9

Please sign in to comment.