mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-05 07:54:35 +02:00
Allow to specifiy a path to a builtin ressource via the url field.
This commit is contained in:
parent
d99365f906
commit
2001680542
6 changed files with 192 additions and 10 deletions
|
@ -66,6 +66,11 @@ class AttachmentDeleteListener
|
|||
public function preUpdateHandler(Attachment $attachment, PreUpdateEventArgs $event)
|
||||
{
|
||||
if ($event->hasChangedField('path')) {
|
||||
//Dont delete file if the attachment uses a builtin ressource:
|
||||
if (Attachment::checkIfBuiltin($event->getOldValue('path'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$file = new \SplFileInfo($this->attachmentHelper->placeholderToRealPath($event->getOldValue('path')));
|
||||
$this->attachmentReverseSearch->deleteIfNotUsed($file);
|
||||
}
|
||||
|
@ -81,6 +86,11 @@ class AttachmentDeleteListener
|
|||
*/
|
||||
public function postRemoveHandler(Attachment $attachment, LifecycleEventArgs $event)
|
||||
{
|
||||
//Dont delete file if the attachment uses a builtin ressource:
|
||||
if (Attachment::checkIfBuiltin($event->getOldValue('path'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$file = $this->attachmentHelper->attachmentToFile($attachment);
|
||||
//Only delete if the attachment has a valid file.
|
||||
if ($file !== null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue