Skip to content

fix: Delete files on submission/question/form deletion#3335

Open
Koc wants to merge 1 commit into
mainfrom
feature/delete-files-on
Open

fix: Delete files on submission/question/form deletion#3335
Koc wants to merge 1 commit into
mainfrom
feature/delete-files-on

Conversation

@Koc
Copy link
Copy Markdown
Collaborator

@Koc Koc commented May 15, 2026

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.pdf
  • forms/111 - my super form/4/22 - question1 that was renamed/file2.pdf

And trying to remove question with id 22 Then we will remove all folders: 22 - question1 and 22 - question1 that was renamed.

At the same time if files were moved somewhere outside of the form directory - we will keep them as is.

⚠️ I doubt that this will work fast enough for form with 1000+ submissions. That's why I asked about async job for cleanup.

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.pdf
  • forms/111 - my super form renamed/4/22 - question1 that was renamed/file2.pdf

And 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.


⚠️ If you don't like this business logic - please explicitly explain how it should work for an each scenario and I will adjust code.

🚧 Todo

  • Add tests once I get approval for business logic

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 1.23457% with 80 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/Db/AnswerMapper.php 0.00% 24 Missing ⚠️
lib/Controller/ApiController.php 4.76% 20 Missing ⚠️
lib/Db/SubmissionMapper.php 0.00% 19 Missing ⚠️
lib/Db/FormMapper.php 0.00% 17 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Koc Koc force-pushed the feature/delete-files-on branch 10 times, most recently from cb8497b to 00a550c Compare May 16, 2026 16:44
@Koc Koc force-pushed the feature/delete-files-on branch from 00a550c to 7c73eca Compare May 16, 2026 16:56
@Koc Koc marked this pull request as ready for review May 16, 2026 16:57
@Koc Koc requested review from Chartman123 and susnux May 16, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete uploaded files when answer is deleted

1 participant