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

Allow a recursive option on rmdir #71

Open
amxmln opened this issue Jan 5, 2021 · 6 comments
Open

Allow a recursive option on rmdir #71

amxmln opened this issue Jan 5, 2021 · 6 comments

Comments

@amxmln
Copy link

amxmln commented Jan 5, 2021

The rmdir function in newer versions of Node allows for a recursive option that when set to true makes the command behave more like a rm -rf, which I think can be very useful in many situations (such as deleting a cloned but no longer needed git repo for example).

The documentation of lightning-fs suggests that its rmdir also takes an options object, but I browsing through the source I couldn’t find anything that seemed to be using that object (I might have missed something though 😅). I feel like adding a native recursive option could really benefit the library and perhaps would even allow for a more efficient way than a recursive "rimraf" implemented on top of the library, since if I understood the structure of lightning-fs correctly it should be possible to just gather a list of all inodes contained in the directory, delete them and then delete the directory itself in a single transaction, right?

Sorry if that suggested solution is useless, but I hope the rest of my point still stands.

Keep up the great work! 🎉

@SaadBazaz
Copy link

Needed!

@jcubic
Copy link
Contributor

jcubic commented Nov 26, 2022

@SaadBazaz do you want to contribute?

@SaadBazaz
Copy link

@jcubic I can try giving it a go. Any pointers to where I can start?

@jcubic
Copy link
Contributor

jcubic commented Nov 26, 2022

You should just get familiar with the code, it was a while when I read the code I don't remember where you should start. But there are not much code in this project.

@kaytwo
Copy link

kaytwo commented Apr 1, 2023

FWIW I ran into this issue and just used unlink on a directory and it worked as I expected it to (equivalent to rm -rf). Looking at the implementation, this will probably leave "garbage" in the virtual filesystem, but if you're doing something in an ephemeral filesystem it should probably meet your needs.

@amxmln
Copy link
Author

amxmln commented Apr 2, 2023

Yes, it will not actually delete the files, they will just become inaccessible, because their parent is removed. They will still take up disk space, however, like you said.

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

4 participants