Skip to content

Commit

Permalink
Item11834: Item13364: Suppress noise when copying files
Browse files Browse the repository at this point in the history
Extensions installer now only reports count of files copied. checked-in
or attached, rather than itemizing every file.

If LocalLib.cfg has $ENV{FOSWIKI_ASSERTS} = 1; enabled then the
verbose report is generated.
  • Loading branch information
gac410 committed Apr 10, 2015
1 parent ddb0c17 commit 3fceacb
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions core/lib/Foswiki/Configure/Package.pm
Expand Up @@ -731,6 +731,11 @@ sub _install {
my $simulated = '';
$simulated = 'Simulated - ' if ( $this->option('SIMULATE') );

# Counters for reporting results
my $checkedIn = 0;
my $copied = 0;
my $attached = 0;

unless ( $this->option('EXPANDED') ) {

# Archive not yet expanded
Expand Down Expand Up @@ -883,6 +888,7 @@ sub _install {
my ( $web, $topic ) = $file =~ m/^data\/(.*)\/(\w+).txt$/;
my ( $tweb, $ttopic ) = _getMappedWebTopic($file);

#SMELL Should not try to check in if target web is missing?
if (1) { #Foswiki::Func::webExists($tweb) ) {
my %opts;
$opts{forcenewrevision} = 1;
Expand All @@ -908,13 +914,15 @@ sub _install {

if ( $contents && $Foswiki::Plugins::SESSION ) {
$reporter->NOTE(
"> ${simulated}Checked in: $file as $tweb.$ttopic");
"> ${simulated}Checked in: $file as $tweb.$ttopic")
if DEBUG;
$checkedIn++;
my $meta = Foswiki::Meta->new( $Foswiki::Plugins::SESSION,
$tweb, $ttopic, $contents );

$ok = 0
unless $this->_installAttachments( $reporter, $dir,
"$web/$topic", "$tweb/$ttopic", $meta );
"$web/$topic", "$tweb/$ttopic", $meta, $attached );
$meta->saveAs(%opts) unless $this->option('SIMULATE');
}
next;
Expand All @@ -923,18 +931,22 @@ sub _install {

# Everything else
$err = $this->_moveFile( "$dir/$file", $target, $perms );
$copied++;
if ($err) {
$reporter->ERROR($err);
$ok = 0;
next;
}

# Pick up all Config.spec's
if ( $file =~ m/\/Config.spec$/ ) {
if ( $file =~ m/\/Config.spec$/ && !$this->option('SIMULATE') ) {
Foswiki::Configure::LoadSpec::parse( $target, $spec, $reporter );
}
$reporter->NOTE("> ${simulated}Installed: $file as $target");
$reporter->NOTE("> ${simulated}Installed: $file as $target") if DEBUG;
}
$reporter->NOTE(
"> ${simulated}Installed: $copied files copied; $checkedIn filed checked in, $attached files attached"
);

my $pkgstore = "$Foswiki::cfg{WorkingDir}/configure/pkgdata";
$err = $this->_moveFile(
Expand Down Expand Up @@ -970,6 +982,8 @@ sub _installAttachments {
my $twebTopic = shift; # Mapped target web/topic
my $meta = shift;

#my $attached = shift; # Count of files attached,

foreach my $key ( sort keys %{ $this->{_manifest}{ATTACH}{$webTopic} } ) {
my $file = $this->{_manifest}->{ATTACH}->{$webTopic}->{$key};
my $tfile = _mapTarget( $this->{_root}, $file );
Expand Down Expand Up @@ -1008,7 +1022,8 @@ sub _installAttachments {
$opts{filesize} = $fstats->size;
$opts{filedate} = $fstats->mtime;
$meta->attach(%opts) unless ( $this->option('SIMULATE') );
$reporter->NOTE(" * Attached: $file to $twebTopic");
$reporter->NOTE(" * Attached: $file to $twebTopic") if DEBUG;
$_[0]++; # Update the attached files counter
}
}
return 1;
Expand Down Expand Up @@ -1285,8 +1300,8 @@ sub uninstall {
push( @plugins, $plugName ) if $plugName;
}
if ( scalar(@unpackedFeedback) ) {
$reporter->NOTE("> Removed files:");
$reporter->NOTE(@unpackedFeedback);
$reporter->NOTE( "> Removed " . scalar @unpackedFeedback . " files:" );
$reporter->NOTE(@unpackedFeedback) if DEBUG;
}

if ( $this->can('posuninstall') && !$this->option('SIMULATE') ) {
Expand Down

0 comments on commit 3fceacb

Please sign in to comment.