fix: Delete files on submission/question/form deletion#3335
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
cb8497b to
00a550c
Compare
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
00a550c to
7c73eca
Compare
Chartman123
left a comment
There was a problem hiding this comment.
I've had a first look into the PR and added some comments :)
| * @param Form $form The form | ||
| * @param Question $question The question | ||
| */ | ||
| private function deleteQuestionFolder(Form $form, Question $question): void { |
There was a problem hiding this comment.
Could you please move this to the bottom to the other helper functions? I'd like to have all directly accessible API functions come first.
| /** @var Folder $folder */ | ||
|
|
||
| $fileName = $folder->getNonExistingName($uploadedFile['name']); |
There was a problem hiding this comment.
| /** @var Folder $folder */ | |
| $fileName = $folder->getNonExistingName($uploadedFile['name']); | |
| /** @var Folder $folder */ | |
| $fileName = $folder->getNonExistingName($uploadedFile['name']); |
| /** @var Folder $folder */ | ||
|
|
||
| $file = $userFolder->getById($uploadedFile->getFileId())[0]; |
There was a problem hiding this comment.
| /** @var Folder $folder */ | |
| $file = $userFolder->getById($uploadedFile->getFileId())[0]; | |
| /** @var Folder $folder */ | |
| $file = $userFolder->getById($uploadedFile->getFileId())[0]; |
| * @param int $questionId | ||
| * @return int[] Array of fileIds | ||
| */ | ||
| public function findFileIdsByQuestion(int $questionId): array { |
There was a problem hiding this comment.
This function isn't referenced anywhere?
|
Regarding the logic:
|
I thought that GDPR first and if user really wants to remove his submission - then we should cleanup everything 😄 |
Yes in this case it might make sense, but even then it depends on the contents of the file. In our use case we use the file questions for uploading music for events in our sports club. So when I delete a submission after adding the information to some other file I don't want to delete the file that I've moved to some other directory. |
Closes #2676, #3061 (?)
Covered scenarios
Submission removal
We remove all files for that submission by file id. This means that we will remove file even if it has been moved outside of the form folder.
Question removal
We iterate though all submission and try to remove folder for the question for each submission by prefix
{questionId} -. Imagine that we have next file structure:forms/111 - my super form/3/22 - question1/file1.pdfforms/111 - my super form/4/22 - question1 that was renamed/file2.pdfAnd trying to remove question with id 22 Then we will remove all folders:
22 - question1and22 - question1 that was renamed.At the same time if files were moved somewhere outside of the form directory - we will keep them as is.
Form removal
We remove form folder completely by prefix
{formId} -. Imagine that we have next file structure:forms/111 - my super form/3/22 - question1/file1.pdfforms/111 - my super form renamed/4/22 - question1 that was renamed/file2.pdfAnd trying to remove form with id 111. Then we will remove all folders
At the same time if files were moved somewhere outside of the form directory - we will keep them as is.
🚧 Todo