From: Jan Büren Date: Mon, 20 Dec 2021 08:18:17 +0000 (+0100) Subject: Revert "get_webdav: Zeitstempel vor dem letzten . setzen" X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~268 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=630c1ae7ea6477846e6f03263262a7ffef670caf;p=kivitendo-erp.git Revert "get_webdav: Zeitstempel vor dem letzten . setzen" This reverts commit 1a5f8c48c797b02bf12daaa7fda04b8d5347a6b3. --- diff --git a/SL/File/Backend/Webdav.pm b/SL/File/Backend/Webdav.pm index c457080af..b1e48edf9 100644 --- a/SL/File/Backend/Webdav.pm +++ b/SL/File/Backend/Webdav.pm @@ -186,17 +186,18 @@ sub webdav_path { } $main::lxdebug->message(LXDebug->DEBUG2(), "file_name=" . $dbfile->file_name ." number=".$number); + my @fileparts = split(/_/, $dbfile->file_name); + my $number_ext = pop @fileparts; + my ($maynumber, $ext) = split(/\./, $number_ext, 2); + push @fileparts, $maynumber if $maynumber ne $number; + + my $basename = join('_', @fileparts); + my $path = File::Spec->catdir($self->get_rootdir, "webdav", $::auth->client->{id}, $type, $number); if (!-d $path) { File::Path::make_path($path, { chmod => 0770 }); } - # simply add the timestring before the last . - # fails for .tar.gz but the number extraction algorithm failed for all - # '123 Storno zu 456' cases and doubled the name like: - # Rechnung_123_Storno_zu_456_202113104 Storno zu 456_20211123_113023 - # TODO extension should be part of the File Model (filetype) - my ($filename, $ext) = split(/\.([^\.]+)$/, $dbfile->file_name); - my $fname = $filename . '_' . $dbfile->itime->strftime('%Y%m%d_%H%M%S'); + my $fname = $basename . '_' . $number . '_' . $dbfile->itime->strftime('%Y%m%d_%H%M%S'); $fname .= '.' . $ext if $ext; $main::lxdebug->message(LXDebug->DEBUG2(), "webdav path=" . $path . " filename=" . $fname);