What happens to an open file handle on Solaris if the pointed file gets moved or deleted? - solaris

What happens to an open file handle on Solaris if the pointed file gets moved, delete
As per
What happens to an open file handle on Linux if the pointed file gets moved, delete
Linux allows renaming files while there are Open FDs and opened FDs work fine.
Does the same apply to other cases ? e.g. Solaris
Linux => Yes
Windows => No
Solaris ?

Yes. Linux emulates the Unix/Solaris behavior of the file remaining allocated and the file contents being available until it is closed by all processes that have it open. In other words, Linux/Solaris/UNIX all behave the same.

Related

VS Code move Cache location in Windows

I am trying to use models from Hugging Face, but VS code always downloads them into my very limited C: drive; C:\Users\<user>\.cache.
How can I force it to cache to a different drive?
Things I've tried:
Googling: only seen threads for Linux, whose commands do not transfer over. Could not find clear equivalent commands for Windows.
Running a new instance from terminal code --user-data-dir E:/.cache
Fully un-installing VS Code, downloading a portable version, and making a data folder (following these instructions)
All of them still result in caching to C:\Users\<user>\.cache.
From some further research, it appears this is currently not possible.
However, I've found that symlinks is a great temporary workaround. In short,
Create a folder on a drive/partition with an abundance of space, i.e. E:\TempCache
Close any instances of VS Code, if any.
Navigate to C:\Users\<username>\.cache. If there's anything in it, cut them over to E:\TempCache, and delete the whole .cache folder.
Open cmd with admin rights, and enter mklink /J "C:\Users\<name>\.cache" "E:\TempCache". This will re-create an empty .cache folder.
Next time VS Code is ran, it will automatically detect and use the .cache folder on the C drive like nothing changed.

Keep VS Code from creating new directories when file system unmounts

I am running VS Code on a Windows machine running Ubuntu on WSL 2 that mounts a remote drive from a Linux server using FUSE. This allows me to edit comfortably on VS Code while I run the documents on the server and it generally works great. However, if I am editing and my computer loses its Internet connection briefly, the FUSE mount is lost. If I am in the middle of editing and don't notice, then when I save it, VS Code will see nothing in the directory and create a bunch of directories and save the file locally, which is not what I want to do.
For example, I might be editing a file that is in the mount folder, which is the remote mount. I work on the file mount/somedir/somedir2/someFile.txt. If the Internet connection drops, the remote filesystem is unmounted. If I click Ctrl-s, then VS Code sees only an empty folder called mount. It then creates a somedir directory, then a somedir2 directory, then a someFile.txt file, and saves it there. It is often some time before I catch the problem, and while it is resolvable, I end up with multiple versions of the same file (one on my computer and one on the server) and rationalizing the two is a pain and, if I do it wrong, can end up with me losing work and data (which has happened).
Is there a way to tell VS Code to give an error message when attempting to save a file to a suddenly nonexistent directory, rather than creating it automatically for me? That would make my life much easier.

Restore a deleted file in the Visual Studio Code Recycle Bin

Using Visual Studio Code Version 1.8.1 how do I restore a deleted file in the recycle bin?
It uses the normal trash bin of your system. So you can grab it our of there.
In Windows you find it in the explorer, in Linux it is as well in Konquerer / Nemo / ...
First go to Recycle Bin of your local machine.
Your VS code deleted files is there in Recycle Bin.
So, Right click on deleted files and select-> Restore option then your deleted files
will be automatically restored in your VS code.
If you just deleted the file, know that VSCode 1.52 (Dec. 2020) will support:
Undo file operations in Explorer
Explorer now supports Undo and Redo for all file operations: delete, rename, copy, move, new file and new folder.
Make sure the focus is in the Explorer and trigger the Undo or Redo commands and your last file operation will be undone or redone respectively.
Keep in mind that we have separate undo stacks for the editor and the explorer and we choose which one to undo based on focus.
Running on Ubuntu 18.04, with VS code 1.51.0
My deleted files from VS Code are located at:
~/.local/share/Trash/files
Every deleted file have a corresponding .trashinfo file which contains details about where the file is deleted from and deletion date and these are located at:
~/.local/share/Trash/info
More info here.
To search for your deleted files:
find ~/.local/share/Trash/files -name your_file_name
In case you deleted files form a mounted ntfs filesystem, they will be located at:
/path_to_mounted_fs/.Trash-$UID
You can get $UID by doing echo $UID in your terminal.
Hope my case helped!
Click in empty space of VS Code's explorer (it's where you see files listed vertically) and press undo Ctrl + z
It'll recover your permanently deleted files too.
VS Code is a lifesaver. ✌
I know the OP says Recycle Bin. What I do though is recreate the file, especially if it's a single file. And when in the file, I just press CMD+Z (I'm on a Mac) and I get my file back.
Recreate the file in the same directory from where it was
deleted.
CMD+Z inside of the newly created file.
I accidentally discarded changes in the Source Control in VS Code, I just needed to reopen this file and press Ctrl-Z few times, glad that VS Code saves your changes like that.
If you can't find your files in the Windows Recycle Bin as it happended to me
(debugger went rogue and deleted the project folder)
look in the %APPDATA%\Code\User\History\ subfolders sorted by date modified.
There I could retrieve my seemingly lost files.
who still facing the problem on linux
and didnt find it on trash
try this solution
https://github.com/Microsoft/vscode/issues/32078#issuecomment-434393058
find / -name "delete_file_name"
If you have permanently deleted files, on macOS, you can see the history (the last month I guess) in $HOME/Library/Application Support/Code/User/History/. You will have to find your file(s) by looking at each entries.json file in every subfolder and rename the last version of your file.
There is probably a similar way on windows and linux but I don't know the precise paths.
I tried most of the options above but none worked.
What worked for me was clicking and highlighting the folder where the file was deleted from in vscode. Then while it is selected, hit CTRL + Z.
This works on windows.
Hitting CTRL+Z without highlighting that folder didn't work.
Just look up the files you deleted, inside Recycle Bin. Right click on it and do restore as you do normally with other deleted files. It is similar as you do normally because VS code also uses normal trash of your system.
While pushing a repository to Github through Vs Studio code I deleted whole folder and they were not available in Recycle bin also. Here is how I recovered those files.
For Windows.
The method is to restore the previous version of the Drive in which the deleted file existed
I had deleted files from G: drive, the below images are self explanatory
Open properties menu of the drive
In properties go to previous versions tab,
where you can find the previously stored versions of that drive along with date at time of backup
use open or click on restore to get the previous version of that drive.
Note: Manipulations in the drive after restore point won't be available
I am not sure how I deleted a file in VS Code, and couldn't find it in recycle bin. Found the file using the History feature of File Explorer.
A month recovery can be done in visual studio code
1 Right click on file and
2 click Open Timeline and
3 select file from timeline
4 the last time file saved by you
5 and your last change of the file is recovered
NOTE : Not only last but all the previously saved check points can be recoverd from vs code
For Mac, try to search some parts of the code in the deleted file in the following path:
~/Library/Application Support/Code
I found a deleted file in this folder
~/Library/Application Support/Code/Backups
Yes, I know this question is about VS Code but I think I can help someone.
I permanently deleted a file, and I tried all the tips wrote here with no success. So I had to recover the file from OS Linux following this
grep -a -C 500 -F 'Unique string in text file' /dev/sda
It was asked above if there is a way to disable the ability to delete a file you created with an undo (#rochasdv).
There is a new setting to disable undo for file operations:
Explorer: Enable Undo default is warn, confirmation dialog
You can also set it to disable so that your files/folders will not participate in undo operations.
You can alo set it to allow - the pre-new setting situation.
Currently, this new setting is in the Insiders Build v1.64 so it may be in Stable early February, 2022.
I am working on Windows with a Ubuntu WSL. I permanently deleted a file by mistake and was not able to restore it from the recycle bin nor by doing anything else.
I however, was able to get my files content by going to "Timeline" and see all my previous modification (it will open a comparison window).
Hope it will help somebody.
I had the case that I, accidentally, deleted a committed file (git) with a ton of additional uncommitted changes, and I could not get it back. (two days of work! yeah, I know, commit early commit often, I know ...)
I had no linux trash can setup on my docker instance and was developing via remote ssh.
I tried to recreate the file and then do a ctrl+Z to recapture the changes as some suggested here. This did not work for me.
So after a struggle over an hour I finally gave up and thought the changes to the file were lost.
However,
I discarded the changes in git, that the file was deleted.
And THEN I retried ctrl+Z and boom all the changes previously came back
magically!
I was a happy camper!
If your local directory has git initialized and you have not committed the changes that include the delete, you can use git checkout -f to throw away local changes.
If you completely delete any of the components in angular using visual code, you can restore it
Go to Recycle Bin and restore the deleted component that will be restored in the project.

File erased in Eclipse

I have a weird one.
I was working on a project in Eclipse (with CDT) when my computer went blue-screen. I remember saving all the files quite recently before that. The computer rebooted with no problems, but when I opened Eclipse again, the file that I was editing at the time was empty (not deleted, so I can't Restore from Local History). All the other files were intact. What happened, is this a problem with Eclipse or my computer, and how can I retrieve the file?
EDIT: I viewed the file using vim on Cygwin and actually it wasn't empty, it was full of unprintable ^# characters.
Right click on the file and choose 'Replace with > Local History...'. This will show you the last few versions of the file that Eclipse has saved.
Checking local history in eclipse didn't actually show anything, but I did solve it another way. What I did is I went to <workspace>/.metadata/.plugins/org.eclipse.core.resources/.history as suggested here, and sorted the entries by last modified. I scrolled down to the latest entry before the crash, then opened the files inside it one by one until I found the file that was erased.

emacs trips over make-directory: File exists: c:/Users/USER/My Documents/.emacs.d/

I try to install/run emacs on a Win7 64-bit machine after using it for years on a WinXP 32-bit machine and run into a problem I do not find any help for in the documentation or on the web.
Symptom:
when starting runemacs.exe for the first time it creates the file
*C:\Users\USER\My Documents.emacs.d*
as one would expect (for my administrator as well as for my user account)
and comes up operational
from the second start of runemacs.exe it breaks in the startup phase,
displaying the scratch buffer, ringing the warning bell and displaying in
bottom line the error:
File exists: c:/Users/USER/My Documents/.emacs.d/
buffer messages specifies:
make-directory: File exists: c:/Users/USER/My Documents/.emacs.d/
if runemacs was called with a file to open, i.e. because the file type was
associated with it and the file was opened to edit, the file is not open
and ready to be edited, but a file can be opened via the menu File->Open File...
but my configurations in the file
C:\Users\USER\My Documents.emacs
are not loaded
My goal:
I want to regain the way I used emacs on the old WinXP 32-bit system:
click a file associated with emacs, get it opened and ready for editing, get my configurations in .emacs loaded automatically, i.e. work with emacs seamlessly.
Checks done and failed attempts to fix this:
I tried the following newly downloded versions of emacs
emacs-23.4-bin-i386.zip
emacs-23.2-bin-i386.zip (the one I used on the WinXP)
I had the emacs directory containing the directory stucture (bin, etc, ...)
located at:
C:\Program Files (x86)\emacs-23.4\ (my preferred location)
C:\Emacs\emacs-23.4\
in the download directory, where I originally extracted it
My HOME variable points to:
C:\Users\USER\My Documents (default)
C:\Users\USER\My Documents\ (tried)
My PATH variable contains:
C:\Program Files (x86)\emacs-23.4\bin (default)
or the corresponding other locations which I tried
The ownership and permissions of my C:\Users\USER\My Documents.emacs.d
look OK:
owner is the USER (administrator or standard_user)
permissions grant Full Control
Having originally installed emacs to *C:\Program Files (x86)\emacs-23.4*
using the administrator account, I also tried to use user account installation
instead (to check for some non- obvious parameter/access permission not set
right if the admin account is uses for setup)
For the runemacs.exe executable I manually set the compatibility settings to
Windows XP (Service Pack 3)
default setting after unpacking: no compatibility setting enabled
I removed the private configuration file C:\Users\USER\My Documents.emacs
(inherited from my XP installation) to check whether it produces a screw-up
All that did not change a bit of the described symptom, i.e. either I screwed up
in testing the above and missed a particular setting which should work, or I am looking into the wrong direction...
It is still unclear to me whether this has anything to do with:
W7 64-bit vs. XP 32-bit
environmental parameter screw-up
emacs configuration (.emacs, .emacs.d) screw-up
general stupidity (of me ;-)
... and why is it has emacs a problem with it in the first place, that the .emacs.d directory already exists... That should be the standard case...
Any help and wisdom much appreciated.
First of all, nice question. The details and listing of what you've already tried is helpful.
Some points:
Don't have spaces in key paths (Emacs, and %HOME%). Generally, things work
fine. But when things break it's often hard to debug and trace back to the
fact that some package author didn't take spaces properly into account.
Set a HOME environment variable to your %USER_PROFILE%. Make it
%USER_PROFILE%/home if you must, but I use the former.
Start by running emacs without any customization.
runemacs -Q
When that works, add your customizations one at a time.
n.b. This answer is not relevant to the original question (which was about Windows), but may be useful to Unix users searching for this error message
You will get this error also if emacs does not have the correct permissions on the .emacs.d directory.
Check it
ls -ld $HOME/.emacs.d
And make sure the user you are running under has rwx permissions!
I got similar problems when I installed the new version of emacs on a new installation of the ubuntu 12.10. I get the problem fixed by chmod 777 .emacs.d, that is, as the previous post pointed out, the emacs does not have the access right to .emacs.d directory. Hope this help.