Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1320: fix deletion of reused files #1696

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kkoehn
Copy link
Collaborator

@kkoehn kkoehn commented Oct 2, 2024

unsolved problem of deleting reused files, when parent gets deleted

see problem description in #1320

@kkoehn kkoehn requested a review from MrSerth October 2, 2024 22:05
@kkoehn kkoehn self-assigned this Oct 2, 2024
@kkoehn kkoehn linked an issue Oct 2, 2024 that may be closed by this pull request
18 tasks
@kkoehn kkoehn changed the title 1320: add example tests for file overwriting 1320: fix deletion of reused files Oct 2, 2024
Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.77%. Comparing base (972ee15) to head (d27e358).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1696   +/-   ##
=======================================
  Coverage   94.77%   94.77%           
=======================================
  Files         130      130           
  Lines        3330     3330           
=======================================
  Hits         3156     3156           
  Misses        174      174           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MrSerth
Copy link
Member

MrSerth commented Oct 9, 2024

I've spent further time debugging and looking for a solution. Finally, I wasn't able to do so with the current architecture and, hence, need to suggest a major architectural change:

Could you try to perform the necessary changes directly by updating and saving the changes (either with the @task.update method or by first assigning new values and then using @task.save)?

Of course, this means the service will return an altered object, persisted object already and not a modified version (that needs to be save). However, the big advantage is that we can more fine granular control which object gets saved how and don't need to wrap around the Rails magic.

Then, you should wrap the execute block into a database transaction. This allows you to perform the changes (i.e., on files) and they "look" persisted in this transaction even if they are not. You may then also use something like @task.reload to get an updated version of the record and move over to the next parts (i.e., tests, model solutions). If you only want to reload associations, you can do so with @task.association(:tests).reload (to force, use @task.association(:tests).reload(true)).

I am rather confident that we will be able to navigate around the current issue with this approach, even if it changes the API. Hence, I would suggest to follow with this approach.

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.

Check task overwriting through ProFormA
2 participants