Revision 48baa5eb
Von Martin Helmling martin.helmling@octosoft.eu vor etwa 7 Jahren hinzugefügt
SL/File/Backend/Filesystem.pm | ||
---|---|---|
15 | 15 |
sub delete { |
16 | 16 |
my ($self, %params) = @_; |
17 | 17 |
die "no dbfile in backend delete" unless $params{dbfile}; |
18 |
my $backend_data = $params{dbfile}->backend_data; |
|
19 |
$backend_data = 0 if $params{last}; |
|
20 |
$backend_data = $params{dbfile}->backend_data-1 if $params{all_but_notlast}; |
|
21 |
|
|
22 |
if ($backend_data > 0 ) { |
|
23 |
for my $version ( 1..$backend_data) { |
|
18 |
my $last_version = $params{dbfile}->backend_data; |
|
19 |
my $first_version = 1; |
|
20 |
$last_version = 0 if $params{last}; |
|
21 |
$last_version = $params{dbfile}->backend_data-1 if $params{all_but_notlast}; |
|
22 |
$last_version = $params{version} if $params{version}; |
|
23 |
$first_version = $params{version} if $params{version}; |
|
24 |
|
|
25 |
if ($last_version > 0 ) { |
|
26 |
for my $version ( $first_version..$last_version) { |
|
24 | 27 |
my $file_path = $self->_filesystem_path($params{dbfile},$version); |
25 | 28 |
unlink($file_path); |
26 | 29 |
} |
27 |
if ($params{all_but_notlast}) { |
|
30 |
if ($params{version}) { |
|
31 |
for my $version ( $last_version+1 .. $params{dbfile}->backend_data) { |
|
32 |
my $from = $self->_filesystem_path($params{dbfile},$version); |
|
33 |
my $to = $self->_filesystem_path($params{dbfile},$version - 1); |
|
34 |
die "file not exists in backend delete" unless -f $from; |
|
35 |
rename($from,$to); |
|
36 |
} |
|
37 |
$params{dbfile}->backend_data($params{dbfile}->backend_data-1); |
|
38 |
} |
|
39 |
elsif ($params{all_but_notlast}) { |
|
28 | 40 |
my $from = $self->_filesystem_path($params{dbfile},$params{dbfile}->backend_data); |
29 | 41 |
my $to = $self->_filesystem_path($params{dbfile},1); |
30 | 42 |
die "file not exists in backend delete" unless -f $from; |
... | ... | |
32 | 44 |
$params{dbfile}->backend_data(1); |
33 | 45 |
} else { |
34 | 46 |
$params{dbfile}->backend_data(0); |
47 |
} |
|
48 |
unless ($params{dbfile}->backend_data) { |
|
35 | 49 |
my $dir_path = $self->_filesystem_path($params{dbfile}); |
36 | 50 |
rmdir($dir_path); |
37 | 51 |
} |
Auch abrufbar als: Unified diff
Dateimanagement: Checkbox zum Löschen/Umbenennen fehlt teilweise bei ERP-Dokumenten
Umgebaut, damit jede einzelne Version eines Dokumentes löschbar ist
fix #51