From 42178c432e0b9b2aff7ae8ed5172614a6e261651 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 9 Jul 2024 13:21:02 -0600 Subject: [PATCH] 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 --- api/src/Storage/Merge.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/src/Storage/Merge.php b/api/src/Storage/Merge.php index a95a367399..9c4d056682 100644 --- a/api/src/Storage/Merge.php +++ b/api/src/Storage/Merge.php @@ -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)