countvajhula / mindstream

Start writing (or coding), stay focused, don't worry.
Other
31 stars 3 forks source link

Unexpected Deletion of ~/.emacs.d Directory During Routine Operation #31

Open akicho8 opened 2 months ago

akicho8 commented 2 months ago

While following the steps for installation and usage, particularly starting with the command sequence C-c , I encountered a significant issue. The entire contents of my ~/.emacs.d directory, including the .git folder, were completely deleted.

Fortunately, I was able to restore everything from a backup made a few hours prior using Time Machine. However, I am quite concerned about what caused this to happen and would appreciate any insights.

This experience has made me hesitant to continue using the tool. Could you please provide some guidance on what might have gone wrong?

akicho8 commented 2 months ago

I later discovered that the contents of ~/.emacs.d were not deleted but were instead moved to the ~/mindstream/saved directory.

akicho8 commented 2 months ago

I'm quite suspicious. I'm too afraid to install something downloaded from such a source.

countvajhula commented 2 months ago

That is indeed a significant issue!

Btw I noticed in my email that someone posted a suspicious link, and that comment now seems to be deleted. I'm glad you didn't click on it @akicho8 !

Now regarding the issue you reported, my first thought was that maybe you accidentally invoked C-c , s (save session -- which moves the repo to ~/mindstream/saved) while visiting a buffer in your .emacs.d folder, and maybe we are not checking that the buffer is in a known Mindstream path before moving the repo.

The other case when we move a folder is in archiving sessions, but that would move the repo to ~/mindstream/archive rather than /saved, so this suggests that what happened here was specifically a save operation.

I just verified that attempting to save while visiting a buffer in my .emacs.d produces the error:

Debugger entered--Lisp error: (error "Not a mindstream buffer!")

Looking at the condition for how it determines whether it is OK to save the repo, it checks whether either (a) the buffer is in a known mindstream path, i.e. mindstream-path or mindstream-archive-path, or (b) if the buffer is part of an active mindstream session.

So one way in which it could have happened is if you accidentally started a session in your .emacs.d repo (e.g. via C-c , m) and then invoked C-c , s to save the session. Do you think this is likely?

In any case, I think we should consider it a bug and offer additional safeguards against this happening, such as disallowing save if the repo is not specifically at a mindstream path. I will look into it.

countvajhula commented 2 months ago

I just pushed a change that only allows saving sessions if they are at the anonymous path (~/mindstream/anon) or at the archive path (~/mindstream/archive), and not otherwise. I verified that attempting to save my .emacs.d even after starting a mindstream session there does not allow the save, so that if this happens accidentally it would not result in the behavior you encountered.

Wdyt @akicho8 ?