From d3b85ef7231ca3955bb988e7cc2d642e76e171f6 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 20 Mar 2008 22:30:36 +0000 Subject: [PATCH] fixed: errors on package importing are always reported as corrupted packages --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/AssetPackage.pm | 16 ++++++++++++---- lib/WebGUI/Storage.pm | 2 +- lib/WebGUI/i18n/English/Asset.pm | 5 +++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 0e0c2d8cb..e8140a21a 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -10,6 +10,7 @@ - fixed: Matrix assets show pending listings from all matrix assets on a site - fixed: Changing name of Matrix listing leaves discussion forum with old name - fixed: Importing a package can break when updating a pending asset + - fixed: errors on package importing are always reported as corrupted packages 7.5.7 - fixed: HttpProxy mixes original site's content encoding with WebGUI's diff --git a/lib/WebGUI/AssetPackage.pm b/lib/WebGUI/AssetPackage.pm index 509027c5c..ec9447603 100644 --- a/lib/WebGUI/AssetPackage.pm +++ b/lib/WebGUI/AssetPackage.pm @@ -203,6 +203,8 @@ sub importPackage { my $self = shift; my $storage = shift; my $decompressed = $storage->untar($storage->getFiles->[0]); + return undef + if $storage->getErrorCount; my %assets = (); # All the assets we've imported my $package = undef; # The asset package my $error = $self->session->errorHandler; @@ -226,15 +228,16 @@ sub importPackage { my $newAsset = $asset->importAssetData($data); $newAsset->importAssetCollateralData($data); $assets{$newAsset->getId} = $newAsset; - # First imported asset must be the "package" + unless ($package) { $package = $newAsset; } } - - return $package; + return $package + if $package; + return 'corrupt'; } #------------------------------------------------------------------- @@ -307,7 +310,12 @@ sub www_importPackage { } if (!blessed $error) { my $i18n = WebGUI::International->new($self->session, "Asset"); - return $self->session->style->userStyle($i18n->get("package corrupt")); + if ($error eq 'corrupt') { + return $self->session->style->userStyle($i18n->get("package corrupt")); + } + else { + return $self->session->style->userStyle($i18n->get("package extract error")); + } } # Handle autocommit workflows if ($self->session->setting->get("autoRequestCommit")) { diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index 1e8176bec..61a983bf4 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -467,7 +467,7 @@ sub createTemp { } $id =~ m/^(.{2})/; - my $self = {_session=>$session, _id => $guid, _part1 => 'temp', _part2 => $1}; + my $self = {_session=>$session, _id => $guid, _part1 => 'temp', _part2 => $1, _errors => []}; bless $self, ref($class)||$class; $self->_makePath; return $self; diff --git a/lib/WebGUI/i18n/English/Asset.pm b/lib/WebGUI/i18n/English/Asset.pm index 2e96cc69b..6ba3a29de 100644 --- a/lib/WebGUI/i18n/English/Asset.pm +++ b/lib/WebGUI/i18n/English/Asset.pm @@ -26,6 +26,11 @@ our $I18N = { context => q|the question asked of the admin when they click on a missing page| }, + 'package extract error' => { + message => q|Unable to extract package! The package may be corrupt, or there may be a server error preventing packages from being imported.|, + lastUpdated => 1206050885, + }, + 'package corrupt' => { message => q|The package you tried to import appears to be corrupt. We imported up to the point where we detected corruption. If you won't want this portion, roll back your current version tag.|, lastUpdated => 0,