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

Children of released viewmodels can't be reclaimed by another part of the tree #8

Open
chrisandreae opened this issue Jul 13, 2016 · 3 comments

Comments

@chrisandreae
Copy link
Member

When a subtree is deleted, only the root is put into the release pool. This means that if a child node of a deleted subtree is added elsewhere, it will not be resolved from the release pool but instead newly fetched from the database. This newly created update operation conflicts with the delete and fails.

@chrisandreae
Copy link
Member Author

Tentative implementation:

Add parent to release pool entries. When releasing a subtree, put the root element into the release pool (unparented) and then each child that might be subject to recursive destroy/delete into the release pool (with its parent set)

When you reclaim something from the release pool that has a parent, you blank out the link to that child in the parent’s association cache. This has two effects: (1) if the parent is not reclaimed, then when it's destroyed the child will not be recursively destroyed and (2) if the parent is reclaimed, the already-reclaimed child will not be considered a "previous child", and so will have to try taking it (and fail).

Then after run!, can call destroy on all nodes in the release pool without parent set.

@chrisandreae
Copy link
Member Author

question: can we remove elements from a collection association cache?

@thefloweringash
Copy link
Contributor

Note we can't skip permissions checks on reclaiming from deleted parents. This could lead to a theft of a child by "release parent; steal child; reclaim parent" (tricky to express, but conceptually possible). More fundamentally, the ability to delete the parent doesn't imply you can operate on its children(?).

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

No branches or pull requests

2 participants