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

- init

parent 53549e20
Branches
No related tags found
No related merge requests found
package SLUB::LZA::TA::Command::permanent;
use SLUB::LZA::TA -command;
use v5.36;
use SLUB::LZA::TA::Archivematica::Elasticsearch;
use Archive::BagIt;
use File::Find;
use namespace::autoclean;
# VERSION
# ABSTRACT: check permanent volumes via ta-tool
sub abstract {return "check permanent storage of Archival Information System (AIS)";}
my $description=<<"DESCR";
Reports checks about AIS' permanent storage
DESCR
sub description {
return "$description"
}
sub opt_spec {
my @global_opts= SLUB::LZA::TA::common_global_opt_spec();
my @local_opts = (
[]
);
return (@global_opts, [], @local_opts);
}
sub validate_args {
my ($self, $opt, $args) = @_;
SLUB::LZA::TA::common_global_validate($self, $opt, $args);
# no args allowed but options!
$self->usage_error("No args allowed") if @$args;
return 1;
}
sub execute {
my ($self, $opt, $args) = @_;
use Data::Printer; p($opt); p(%SLUB::LZA::TA::config);
my %result;
my @candidates;
my $wanted = sub {
my ($dev,$ino,$mode,$nlink,$uid,$gid);
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
-f _ &&
/^bag-info\.txt\z/s &&
($File::Find::prune = 1)
&& push @candidates, $File::find::dir;
};
File::Find::find({wanted => $wanted}, @{ $SLUB::LZA::TA::config{permanent_volume} } );
foreach my $candidate (@candidates) {
my $bag = Archive::BagIt->new($candidate);
my $is_valid = $bag->verify_bag();
$result{$candidate} = $is_valid;
say "$candidate is " . ($is_valid ? "valid" : "invalid");
}
return 1;
}
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment