Cron-Import: Originale Dateinamen beim Archivieren beibehalten

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eduard Wisch 2026-02-23 19:25:38 +01:00
parent a2c492d833
commit 59ce17b7b5

View file

@ -598,7 +598,17 @@ class CronImportZugferd
}
if (is_dir($targetFolder) && is_writable($targetFolder)) {
$targetPath = $targetFolder . '/' . $prefix . date('Y-m-d_His') . '_' . basename($file);
// Originalen Dateinamen beibehalten, bei Namenskollision Zaehler anhaengen
$baseName = basename($file);
$targetPath = $targetFolder . '/' . $baseName;
if (file_exists($targetPath)) {
$pathInfo = pathinfo($baseName);
$counter = 1;
do {
$targetPath = $targetFolder . '/' . $pathInfo['filename'] . '_' . $counter . '.' . $pathInfo['extension'];
$counter++;
} while (file_exists($targetPath));
}
if (@rename($file, $targetPath)) {
dol_syslog("CronImportZugferd: Moved file to: " . $targetPath, LOG_INFO);