问题
My machine went off recently without shutting down and my IDEA workspace seems to be different. The file I was working on now only has a blank spaces. and the local history for it is empty how can I get this file back. The file is more than 6 months old. I really don't know what to do. Is there a way I can recover from past local histories or the cache?
回答1:
Empty Local History may indicate corrupted indices. Probably the shutdown occurred right in the middle of some write operation. If you have an old IntelliJ config folder though, you could try opening the project in old version so it could use those indices, or try copying them to the new version to check if it helps.
IntelliJ uses safe write to prevent data loss when save operation is interrupted - it creates a temp file near the actual one, saves there, and if save was successful, removes the original one and renames the temp. So check if there is still a copy around the problematic file.
Wasn't the file added to some VCS? The best practice is to track in VCS all important files.
回答2:
How I finally solved it:
I tried using recuva to get the delete history from my src
folder, I was able to get the jb_bak and jb_old of the blank file.
wasn't able to recover the original file from the jb_bak or jb_old though.
I downloaded easus data recovery wizard
and specified my project's jar production in order to recover the deleted class outputs(since my src
class files were overwritten already) i.e.
C:
\ IdeaProjects
\ Yuppies
\ src
\ main
\ resources
\ Jars
\ out
\ production
\ Jars
\ yars
\ ...
Yars
was the folder containing my classes @src
For anyone who runs into this similar problem you may want to try checking the following paths as it applies for your project(my project's name was Yuppies ) if the above doesn't work or if you want to compare results above with these so you can get the copy of your file with the largest size/the most recent update:
C:\IdeaProjects\
Yuppies
\target\classes\Jars\out\production\Jars\yars
\ ...
OR
C:\IdeaProjects\
Yuppies
\target\classes\yars
\ ...
If that doesn't work too try checking if intellij built a jar of the original class @
C:\IdeaProjects\
Yuppies
\target\classes\Jars\out\artifacts\ ...
and see if you can decompile the jar file.
来源:https://stackoverflow.com/questions/54035963/how-do-i-recover-previous-local-histories