Sublime Forum

Why is atomic save useful?

#1

is there a particular situation where atomic saves are better than the current implementation?

0 Likes

Lag on saving
#2

Atomic saves are preferable because you will never end up with a mangled file if anything untoward happens while saving.

0 Likes

#3

got it thanks! (any drawbacks for atomic saving?)

0 Likes

#4

You can loose meta data about the file, such as extended attributes and resource forks. OS X and Windows both provide APIs to preserve the metadata, which Sublime Text uses, but these won’t work in all scenarios (e.g., over some network drives), and there’s no equivalent on Linux. You can also get into trouble if editing a file in a directory with strange permissions, e.g., if it’s setup to allow modifying existing files, but not create new ones.

0 Likes

#5

thanks, much appreciated!

0 Likes

#6

It also looses symlinks and that is very annoying.

0 Likes

#7

Just remember that atomic save is notoriously bugged in Sublime Text (at least versions 2 and 3), and should not be used until the bugs have been fixed :smile:

0 Likes

#8

Considering Sublime Text 2 doesn’t even have the concept of atomic saves - you might want to take this statement with a grain of salt.

0 Likes

#9

Typo from my point :smile: see these posts for a description of the problem:


viewtopic.php?f=3&t=12660&start=0

0 Likes

#10

Just for the record: disable this trick in preferences if you want file updates to be visible to concurrent processes by normal means.

i.e. with the default setting, another process that has open(2)'d a file you then open, edit and save with Sublime won’t see those changes because they’re made to a different underlying file.

0 Likes

#11

If your having issues with saved files not being synced to a vagrant box, this setting is the culprit.
set it to false to fix.

0 Likes

#12

I have to use atomic saving, because I have a remote drive hooked up as a mounted Windows SFTP drive. Without atomic_save being “false” it fails whenever I try to save a document.

Unfortunately, there’s no way to say “atomic save on drive Q” and “non-atomic-save on every other drive”.

I created a userecho request to do this: sublimetext.userecho.com/topic/516558-/

0 Likes

#13

It should just be disabled. In theory, atomic saving is a good idea, but in practice it just doesn’t work. Also, most file watchers will not understand what’s happening with the file (deleted, then another file renamed) and do something unpredictable.

Atomic saving should be done at the OS level imo with a specific API for that which works around all these issues, not by an application.

0 Likes

#14

I also recommend disabling this feature (which I believe should be its default state). I learned of its adverse effects the hard way. I was editing files in a versioned SharePoint document library. Atomic save’s process of deleting the original file and renaming the .tmp file to the original file name completely wiped out all previous versions of the documents I was editing. So much for our audit trail!

0 Likes