From: Bernd Bleßmann Date: Mon, 25 Apr 2022 14:34:51 +0000 (+0200) Subject: SL:Webdav:File.pm->store: ungeänderte Dokumente nicht doppelt speichern. X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~43 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=95b5d54bac9dc0cb47c67444c9e19c1d68b0d520;p=kivitendo-erp.git SL:Webdav:File.pm->store: ungeänderte Dokumente nicht doppelt speichern. Einfacher Größenvergleich mit letzter Version. --- diff --git a/SL/Webdav/File.pm b/SL/Webdav/File.pm index 313c9ff31..54af37a3a 100644 --- a/SL/Webdav/File.pm +++ b/SL/Webdav/File.pm @@ -58,6 +58,19 @@ sub store { $params{new_version} = 1; } + # Do not create a new version of the document if file size of last version is the same. + if ($params{new_version}) { + my $last_file_size = $last->size; + my $new_file_size; + if ($params{file}) { + croak 'No valid file' unless -f $params{file}; + $new_file_size = (stat($params{file}))[7]; + } else { + $new_file_size = length(${ $params{data} }); + } + $params{new_version} = 0 if $last_file_size == $new_file_size; + } + if ($params{new_version}) { my $new_version = $self->webdav->version_scheme->next_version($last); my $sep = $self->webdav->version_scheme->separator; @@ -153,6 +166,9 @@ C and C are exclusive. If param C is set, force a new version, even if the versioning scheme would keep the old one. +No new version is stored if the file or data size is euqal to the size of +the last stored version. + =back =head1 SEE ALSO diff --git a/SL/Webdav/Object.pm b/SL/Webdav/Object.pm index 8779d0961..e4ece7969 100644 --- a/SL/Webdav/Object.pm +++ b/SL/Webdav/Object.pm @@ -42,6 +42,10 @@ sub full_filedescriptor { File::Spec->catfile($self->webdav->webdav_path, $self->filename); } +sub size { + ($_[0]->stat)[7]; +} + sub atime { DateTime->from_epoch(epoch => ($_[0]->stat)[8]); } @@ -132,6 +136,10 @@ Returns the version string. Returns the extension. +=item C + +wrapped stat[7] + =item C L wrapped stat[8]