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

Make deleting directories more convenient #16

Open
TadLeonard opened this issue Sep 12, 2018 · 1 comment
Open

Make deleting directories more convenient #16

TadLeonard opened this issue Sep 12, 2018 · 1 comment

Comments

@TadLeonard
Copy link
Owner

Per @hntuan94, it would be convenient if tfatool exposed a delete_directory function. This function would:

  • walk through the directory and delete any files within
  • when the directory's empty, it'd delete the directory itself

The challenge here is to be absolutely sure it's empty before deleting. Listing the contents of the directory before making the final delete would be a good idea. Care is needed because FlashAir will let you delete a directory that isn't empty, but the files within will become unreadable and undeletable forever afterwards. Scary!

@TadLeonard
Copy link
Owner Author

TadLeonard commented Sep 16, 2018

Alternatively, the function could play it safe and:

  • check whether the directory's empty, raise an exception if it's not
  • delete the directory

We could then expose a separate function for deleting a list of files, whose usage pattern would look like:

  • files_to_delete = command.list_files("directory", session)
  • upload.delete_files(files_to_delete, session)
  • upload.delete_directory("directory", session)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant