Skip to content

Conversation

Klairm
Copy link

@Klairm Klairm commented Nov 17, 2024

Currently when trying to discard files that are directories, the IsDirectoryError is thrown.

imagen

The current commit fixes the error and creates correctly the backup files, but I haven't been able to locate where the removing is performed in all the codebase, so that part is still missing.

When trying to discard files that are directories, the
IsDirectoryError is thrown
@jorio
Copy link
Owner

jorio commented Nov 17, 2024

Good catch! Thank you for the PR. Deleting an untracked tree is an edge case that I hadn't considered.

Thinking about it, I think I'd create a tarball of the deleted tree and save that in the trash instead of copying the tree. That way it won't throw off the trash's file count model, and cleanup would be easier (os.unlink won't work on directories).

But beyond the trash mechanism, the actual deletion task (DiscardFiles) ultimately calls into pygit2's checkout_index, which apparently has no effect on untracked trees. I'll think about how to solve this!

jorio added a commit that referenced this pull request Nov 19, 2024
@jorio
Copy link
Owner

jorio commented Nov 19, 2024

726d515 backs up an untracked tree as a tarball (if it's smaller than the threshold in Settings > Trash) and deletes the tree from the working directory.

Thank you for raising this! I've also noted that attempting to discard the deletion of a non-submodule tree currently errors out as well, so I'll fix that next. Feel free to open a new issue if you find more problems with trees (or anything else).

@jorio jorio closed this Nov 19, 2024
@Klairm
Copy link
Author

Klairm commented Nov 19, 2024

726d515 backs up an untracked tree as a tarball (if it's smaller than the threshold in Settings > Trash) and deletes the tree from the working directory.

Thank you for raising this! I've also noted that attempting to discard the deletion of a non-submodule tree currently errors out as well, so I'll fix that next. Feel free to open a new issue if you find more problems with trees (or anything else).

You're welcome! I wanted to contribute if possible but don't have much time at the moment, glad you fixed!

Since I'll be using the program I'll open a issue when needed

😄

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.

2 participants