Api: If merge option "link to each entry" is used, move the generated file to entry's vfs directory instead of link from generated directory

This should reduce filename conflicts and avoid accidental deletions
This commit is contained in:
nathan 2024-07-09 13:21:02 -06:00
parent fbb3c22d38
commit 42178c432e

View File

@ -2561,17 +2561,22 @@ abstract class Merge
$converted = $document_merge->pdf_conversion($target);
$target = $converted;
}
$merged[] = $target;
$attach[] = Vfs::PREFIX . $target;
// Move to entry
if($link)
{
foreach((array)$ids as $id)
{
// Copy to entry
Api\Link::link($app, $id, Api\Link::VFS_APPNAME, Vfs::PREFIX . $target);
// Remove
Vfs::unlink($target);
$target = Api\Link::vfs_path($app, $id, Vfs::basename(Vfs::PREFIX . $target));
}
}
$merged[] = $target;
$attach[] = Vfs::PREFIX . $target;
}
// One email per id group
if($email && $mail_bo)