FriendsOfCake / cakephp-upload

CakePHP: Handle file uploading sans ridiculous automagic
https://cakephp-upload.readthedocs.io/
MIT License
551 stars 255 forks source link

keepFilesOnDelete not removing all files #465

Closed kojot1234 closed 7 years ago

kojot1234 commented 7 years ago

Problem only occurs when the first file in the field list is empty but the next one exists.

Since afterDelete runs through all configuration fields if it fails on the first field it exits and will not remove any other files that were marked for removal with keepFilesOnDelete.

afterDelete should either continue on unsuccessful deletion or delete should not happen at all.

UploadBehavior.php

public function afterDelete(Event $event, Entity $entity, ArrayObject $options)
{
     ...
     if ((new Collection($success))->contains(false)) {
          continue; // return false;
     }
     ...
}
saeideng commented 7 years ago

you see deleteCallback option ?

kojot1234 commented 7 years ago

Yes, that's how I got around right now but it seems like an unneeded workaround. I'm assuming the intended functionality should loop through and remove all fields set in the configuration and not quit on the first removal. Correct me if I'm wrong.

josegonzalez commented 7 years ago

Mind making a pull request?

jorisvaesen commented 7 years ago

Closed as there is a PR open.