Stop resaving when no changes are made

It appears that if I open a .scriv project, make no changes, and close the project, it gets written to disk. That seems dangerous. Is there a reason this must be done?

What specific evidence do you have that any saving is going on?

A Scrivener project isn’t actually an individual file (although it looks like one on the hard drive, but that is only because of an OS X feature that allows the internal contents to be hidden). Instead, it is really a folder (a special kind of folder called a “package”) that holds many sub-files. The way that a Scrivener project works is that when you open the project, a file called the “binder file” is loaded into memory (that displays the contents of the binder on the left side of the interface). When you select an individual item in the binder, that item is a separate file that gets loaded. When you change to a different binder item, the previous item is unloaded (saved, if necessary) and then the new item is loaded. So as you navigate around the project, various sub-files are being loaded and unloaded all the time. But they are only “saved” if they are modified. The project as a whole is never loaded all at once, nor saved all at once.

However, there are also a bunch of sub-files that contain information about the project without holding any of the content (at least, not what you’d think of as content). For example, there is a file in every project called “ui.plist” which saves a bunch of state information about the interface. For example, it remembers which binder item you last selected so that it can re-select that same item the next time you load the project. It saves lots of other non-critical information as well, such as the width of the individual interface elements (like the binder and inspector panels).

The “ui.plist” file is saved every single time you open the project, even if you don’t make any changes, because it is a snapshot of the application’s state upon close. But this is perfectly safe. That file is saved without the rest of the files in the project package being updated. And if something goes really wrong with the ui.plist file, it can simply be deleted to solve the problem (because it doesn’t contain any content, just state information).

There are also a couple of internal backups created of the “binder file” when opening and closing a project. This is part of Scrivener’s safety precautions (which guard against a wide variety of problems), and it happens regardless of whether or not you make changes to the project. But again, the creation of these temporary files is for safety, and it isn’t the same thing as the content of the project being re-saved.

My guess is that you opened the project, navigated around a bit, and then closed it. You noticed that the file’s modified date had been updated, and were under the impression that the entire project has been re-saved. But that isn’t what happens at all. In all likelihood, only the ui.plist file (and maybe one of the other state files) was updated, plus the binder backups were updated. However, if any subfile within a project is changed, it will change the file modification date of the entire package. But content that wasn’t changed isn’t really being re-saved.