Sublime Forum

Editing a file which has a hardlink

#1

Hi,
I’m using ST3 on Ubuntu Linux and find a strange behaviour. I have a text file and another file which is its hardlink. When I try to edit one of them the linkage gets broken. I noticed that the inode of the file is changed immediately after resaving it in ST3 so I do expect that ST3 uses some temporary file and copies it into right location when saving. Can this behaviour be disabled somehow?

thanks
Jan

0 Likes

#2

Check out this setting:

// Save via writing to an alternate file, and then renaming it over the // original file. "atomic_save": true,

0 Likes

#3

Thank you for the answer. Maybe it could be useful to automatically disable atomic save when editing a file which has 2 or more links.

regards
Jan

0 Likes

#4

[quote=“xhpohanka”]Thank you for the answer. Maybe it could be useful to automatically disable atomic save when editing a file which has 2 or more links.

regards
Jan[/quote]

That would be very useful indeed. I absolutely need atomic save enabled for certain files (.scss files), but for a few other files (which are also hard links) I must not use atomic save or else the hard link will break.

Is there a way to enable atomic save only for certain file extensions (.scss)? Or alternatively, sublime text should check if a file is a hard link before saving the file the atomic way (write, rename, delete)

0 Likes

#5

could be done via plugin: listen to on_pre_save check if the file has hardlinks via lstat and change the global save_atomic value. sounds like an 20 lines code thing to me

0 Likes