blob: 9ba8b40c36c4aaf0f9a5ed1c90e58e6350e78d1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package App::Glacier::Command::DeleteFile;
use strict;
use warnings;
use App::Glacier::Command::ListVault;
use parent qw(App::Glacier::Command::ListVault);
use App::Glacier::Command;
use App::Glacier::HttpCatch;
=head1 NAME
glacier rm - remove file from a vault
=head1 SYNOPSIS
B<glacier rm>
I<VAULT>
I<FILE>...
=head1 DESCRIPTION
Removes listed files from the vault. I<FILE> can contain version numbers,
to select particular version of the file. Globbing patterns are also allowed.
=head1 SEE ALSO
B<glacier>(1)
=cut
sub run {
my $self = shift;
$self->abend(EX_USAGE, "at least two arguments expected") unless @_ >= 2;
my $vault_name = shift;
my $dir = $self->directory($vault_name);
my $error = 0;
my $success = 0;
foreach my $ref (@{$self->get_vault_inventory($vault_name, @_)}) {
$self->glacier_eval('delete_archive', $vault_name, $ref->{ArchiveId});
if ($self->lasterr) {
$self->error(EX_FAILURE,
"can't remove file \"$ref->{FileName};$ref->FileVersion}\":",
$self->last_error_message);
$error++;
} else {
$dir->delete_version($ref->{FileName}, $ref->{FileVersion});
$success++;
}
}
exit(EX_TEMPFAIL) if $error;
}
1;
|