Skip to content
Snippets Groups Projects
Verified Commit d1a17dab authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- refactoring, extracted check_a_bag()

parent 4587024d
Branches
Tags
No related merge requests found
...@@ -45,9 +45,23 @@ sub validate_args { ...@@ -45,9 +45,23 @@ sub validate_args {
return 1; return 1;
} }
sub check_a_bag ($candidate) {
my $bag = Archive::BagIt->new($candidate);
# explicite SHA loading, because
# Archivematica only use SHA512, but have version 0.97
$bag->use_plugins('Archive::BagIt::Plugin::Algorithm::SHA512');
my $is_valid;
eval {
$is_valid = $bag->verify_bag({report_all_errors => 1});
};
my $line;
$line->{'AIP storage path'} = $candidate;
$line->{'bagit validation result'} = ($is_valid ? "valid" : "invalid");
return $line;
}
sub execute { sub execute {
my ($self, $opt, $args) = @_; my ($self, $opt, $args) = @_;
my @candidates; my @candidates;
my $wanted = sub { my $wanted = sub {
my ($dev, $ino, $mode, $nlink, $uid, $gid); my ($dev, $ino, $mode, $nlink, $uid, $gid);
...@@ -63,19 +77,7 @@ sub execute { ...@@ -63,19 +77,7 @@ sub execute {
@{ $SLUB::LZA::TA::config{permanent_volume} } @{ $SLUB::LZA::TA::config{permanent_volume} }
); );
my @results = map { my @results = map {
my $candidate = $_; check_a_bag( $_ );
my $bag = Archive::BagIt->new($candidate);
# explicite SHA loading, because
# Archivematica only use SHA512, but have version 0.97
$bag->use_plugins('Archive::BagIt::Plugin::Algorithm::SHA512');
my $is_valid;
eval {
$is_valid = $bag->verify_bag({report_all_errors => 1});
};
my $line;
$line->{'AIP storage path'} = $candidate;
$line->{'bagit validation result'} = ($is_valid ? "valid" : "invalid");
$line;
} (sort @candidates); } (sort @candidates);
my @headers = sort keys %{$results[0]}; my @headers = sort keys %{$results[0]};
my $misc_ref; my $misc_ref;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment