Revision 19727dec
Von Tamino Steinert vor 9 Monaten hinzugefügt
SL/File/Backend/Filesystem.pm | ||
---|---|---|
22 | 22 |
sub delete { |
23 | 23 |
my ($self, %params) = @_; |
24 | 24 |
die "no dbfile in backend delete" unless $params{dbfile}; |
25 |
my @versions = @{$params{dbfile}->file_versions_sorted}; |
|
26 | 25 |
|
27 | 26 |
my @versions_to_delete; |
28 |
if ($params{last}) { |
|
29 |
my $last = pop @versions; |
|
30 |
@versions_to_delete = ($last); |
|
31 |
} elsif ($params{all_but_notlast}) { |
|
32 |
pop @versions; # remove last |
|
33 |
@versions_to_delete = @versions; |
|
34 |
} elsif ($params{version}) { |
|
35 |
my $version = first {$_->version == $params{version}} @versions |
|
36 |
or confess "Version not found."; |
|
37 |
@versions_to_delete = ($version); |
|
27 |
if ($params{file_version}) { |
|
28 |
croak "file_version has to be of type SL::DB::FileVersion" |
|
29 |
unless ref $params{file_version} eq 'SL::DB::FileVersion'; |
|
30 |
@versions_to_delete = ($params{file_version}); |
|
38 | 31 |
} else { |
39 |
@versions_to_delete = @versions; |
|
32 |
my @versions = @{$params{dbfile}->file_versions_sorted}; |
|
33 |
if ($params{last}) { |
|
34 |
my $last = pop @versions; |
|
35 |
@versions_to_delete = ($last); |
|
36 |
} elsif ($params{all_but_notlast}) { |
|
37 |
pop @versions; # remove last |
|
38 |
@versions_to_delete = @versions; |
|
39 |
} else { |
|
40 |
@versions_to_delete = @versions; |
|
41 |
} |
|
40 | 42 |
} |
41 | 43 |
|
42 | 44 |
foreach my $version (@versions_to_delete) { |
Auch abrufbar als: Unified diff
File: Löschen über die guid der Version