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

Fix critical bug in delete_tree #835

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

Conversation

danielballan
Copy link
Member

The delete_tree deletes nodes recursively. It was added specifically to support tiled serve directory --watch ..., which blows and rebuilds the database when files change (as an initial simple/safe implementation).

Crucially, it can only ever delete registered data, never user-uploaded data. Which is a good thing because, as implemented, it always deletes the entire tree---not from a prescribed node downward but always from the root. Bad bug!

This bug was masking other bugs, also fixed here. Needs tests, but here's a demo of the intended behavior working as planned on this PR branch:

In [1]: from tiled.client import from_uri, show_logs, tree

In [2]: c = from_uri('http://localhost:8000', api_key='secret')

In [3]: c.create_container(key='A')
   ...: c.create_container(key='B')
Out[3]: <Container {}>

In [4]: c['A'].create_container('a1')
Out[4]: <Container {}>

In [5]: tree(c)
├── A
│   └── a1
└── B

In [6]: c['A'].delete_tree()

In [7]: tree(c)
├── A
└── B

In [8]: c.delete('A')

In [9]: tree(c)
└── B

Checklist

  • Add a Changelog entry
  • Add the ticket number which this PR closes to the comment section

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.

1 participant