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

Beautify Directory erases every file #213

Open
cyberwombat opened this issue Feb 14, 2015 · 11 comments
Open

Beautify Directory erases every file #213

cyberwombat opened this issue Feb 14, 2015 · 11 comments

Comments

@cyberwombat
Copy link

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 Glavin001 self-assigned this Feb 15, 2015
@Glavin001 Glavin001 added this to the v1.0.0 milestone Feb 15, 2015
@Glavin001 Glavin001 changed the title Erases every file when used globally Beautify Directory erases every file Feb 15, 2015
@Glavin001
Copy link
Owner

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

To prevent accidental usage:

  • add warning before applying beautify directory as this is recursive and can cause damage when applied to too many files, as mentioned above

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

  • only allow maximum number of files to be beautified
  • if beautification result is an empty string, do not save this to file (do not allow file contents to go to being empty and then save that empty result)
  • show progress of beautification in modal
    • allow mass-beautification to be paused/stopped
      • do not attempt to beautify all N (let's say 1000 files) at once, and instead do X (10?) in parallel and sequentially work through them, so long as it's not stopped
    • show errors
    • show completed
    • show pending

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

@cyberwombat
Copy link
Author

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
Copy link
Owner

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
Copy link

sunglee commented Mar 11, 2015

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

@cyberwombat
Copy link
Author

@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
Copy link
Owner

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
Copy link
Owner

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

  • remember original file contents so that Beautification can be reverted

@cyberwombat
Copy link
Author

@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
Copy link
Owner

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
Copy link
Author

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

@Glavin001
Copy link
Owner

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 [email protected] 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:
#213 (comment)

@Glavin001 Glavin001 modified the milestones: v0.26.0, v0.25.0, v0.27.0 May 3, 2015
@Glavin001 Glavin001 modified the milestones: v0.29.0, v0.28.0 May 28, 2015
Glavin001 added a commit that referenced this issue Jun 10, 2015
- and do not save beautified output if it is empty string
@Glavin001 Glavin001 added this to the v0.30.0 milestone Mar 30, 2016
@Glavin001 Glavin001 removed this from the v0.29.0 milestone Mar 30, 2016
@Glavin001 Glavin001 modified the milestones: v0.30.0, v0.31.0 Jun 22, 2017
@Glavin001 Glavin001 modified the milestones: v0.31.0, v0.33.0 (Next) Mar 2, 2018
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

3 participants