From: Martin Helmling martin.helmling@octosoft.eu Date: Sat, 30 Sep 2017 13:24:27 +0000 (+0200) Subject: Dateimanagment: itime/mtime in DB kann gesetzt werden, mtime kann in Filesystem-Backe... X-Git-Tag: release-3.5.4~710 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=74d8dd6f77ff33f496cac0fc1c715c167232a5ca;p=kivitendo-erp.git Dateimanagment: itime/mtime in DB kann gesetzt werden, mtime kann in Filesystem-Backend gesetzt werden Wird benötigt falls man bestehende Dateien übernehmen will --- diff --git a/SL/File.pm b/SL/File.pm index 329697474..830559460 100644 --- a/SL/File.pm +++ b/SL/File.pm @@ -220,6 +220,8 @@ sub _save { title => $params{title}, description => $params{description}, ); + $file->itime($params{mtime}) if $params{mtime}; + $params{itime} = $params{mtime} if $params{mtime}; } } else { $exists = 1; @@ -236,12 +238,14 @@ sub _save { # load itime for new file $file->save->load; } - $main::lxdebug->message(LXDebug->DEBUG2(), "backend3=" .$file->backend); + + $file->mtime(DateTime->now_local) unless $params{mtime}; + $file->mtime($params{mtime} ) if $params{mtime}; + my $backend = $self->_get_backend($file->backend); $params{dbfile} = $file; $backend->save(%params); - $file->mtime(DateTime->now_local); $file->save; #ShopImage if($file->object_type eq "shop_image"){ diff --git a/SL/File/Backend/Filesystem.pm b/SL/File/Backend/Filesystem.pm index c42707d6c..ec67d7414 100644 --- a/SL/File/Backend/Filesystem.pm +++ b/SL/File/Backend/Filesystem.pm @@ -79,6 +79,9 @@ sub save { print OUT $params{file_contents}; close(OUT); } + if ($params{mtime}) { + utime($params{mtime}, $params{mtime}, $tofile); + } return 1; } diff --git a/scripts/sync_files_from_backend.pl b/scripts/sync_files_from_backend.pl index 26626e1b2..2c361483f 100755 --- a/scripts/sync_files_from_backend.pl +++ b/scripts/sync_files_from_backend.pl @@ -82,7 +82,7 @@ parse_args(\%config); setup(); SL::File->sync_from_backend( file_type => 'document'); -SL::File->sync_from_backend( file_type => 'attachments'); -SL::File->sync_from_backend( file_type => 'images'); +SL::File->sync_from_backend( file_type => 'attachment'); +SL::File->sync_from_backend( file_type => 'image'); 1;