Glavin001 / atom-beautify

:mega: Help Wanted - Looking for Maintainer: https://github.com/Glavin001/atom-beautify/issues/2572 | :lipstick: Universal beautification package for Atom editor (:warning: Currently migrating to https://github.com/Unibeautify/ and have very limited bandwidth for Atom-Beautify Issues. Thank you for your patience and understanding :heart: )
http://unibeautify.com/
MIT License
1.5k stars 453 forks source link

`Beautify Directory` erases every file #213

Open cyberwombat opened 9 years ago

cyberwombat commented 9 years ago

So recently the command has appeared "beautify directory" - where it used to just say "seach directory". I accidently hit it while searching in my project and it locked up and erased every. single. file. 1000's of files, the entire project completely blank. Im gonna go get drunk now. I dont have anything else to go on except there is a serious serious issue here.

Glavin001 commented 9 years ago

This is a very serious issue, on a few fronts. Thank you for sharing.

To prevent accidental usage:

Fix issue that files become completely blank. This seems to occur when a massive number of files are beautified with beautify directory. Unfortunately, when beautifying, there is no way to stop the beautification process and can lock up Atom and also result in the files being blank

I apologize for any inconvenience this may have caused. Thank goodness for version controlling projects. This is top priority issue.

cyberwombat commented 9 years ago

I would also add a setting to turn off the sidebar menu entry. I went and just edited the cson file. My need to beautify an entire project/directory is zero and that menu entry is the top one for me - I prefer to just do it on a file by file basis.

Thanks for you prompt attention!

Glavin001 commented 9 years ago

I would also add a setting to turn off the sidebar menu entry

I am not sure how I would go about this programmatically. Does Atom have an API for me to disable menu entries after the fact (loaded from the .cson file)?

sunglee commented 9 years ago

Please change name "Beautify Directory" to "Delete all your file" :-1: Another victim of the stupid name. Sad...

cyberwombat commented 9 years ago

@sunglee Wow bummer.. I feel you. Not sure if it's of any use for you but when I tried to find if any of my files has somehow been cached/saved the only potential one (which did not work for me sadly) was that if you are on a mac with time machine on (even if your drive is not plugged in) and there is at least 20% free space, that time machine will do a local save every hour. Unfortunately my disk did not have enough room so I lost everything since last commit.

Glavin001 commented 9 years ago

I am going to publish with Beautify Directory disabled until this is resolved. As much as it works when I use it, it does cause problems when you are beautifying too many files and other cases.

Glavin001 commented 9 years ago

Published to v0.21.5

Please update immediately to ensure this issue does not cause problems for you again until it is resolved.

I would also like to implement

cyberwombat commented 9 years ago

@Glavin001 isn't there a way to modify things so that it does one file at the time instead of what I am assuming is to load a billion files in memory?

Glavin001 commented 9 years ago

Here's the applicable code for beautifying a directory: https://github.com/Glavin001/atom-beautify/blob/master/lib/beautify.coffee#L190-L211

Changing async.each instead to async.eachSeries would do what you suggest, @cyberwombat. It would likely slow things down and not be maximizing usage of Node.js: high I/O operations and waiting for each file sequentially, instead of what is currently done now which is processing another file while another slow beautification is in progress.

cyberwombat commented 9 years ago

Perhaps a balance - I have not used this myself but mapLimit or some other tool might be of use

Glavin001 commented 9 years ago

I absolutely agree. Either mapLimit or probably eachLimit. And have the limit be able to be configured by users too. Good thinking  

— Sent from Mailbox

On Wed, Mar 11, 2015 at 1:36 PM, Yashua notifications@github.com wrote:

Perhaps a balance - I have not used this myself but mapLimit or some other tool might be of use

Reply to this email directly or view it on GitHub: https://github.com/Glavin001/atom-beautify/issues/213#issuecomment-78301244