Skip to content

Redo settings mechanism #959

Open
Open

Description

@clairernovotny

The current mechanism is based on .NET's built-in Settings serialization class. It's not clear why, but sometimes serlialization gets messed up and the file corrupted.

We should take a fresh look at how settings should be persisted.

Activity

  1. adamfoneil commented on Apr 28, 2020

    @adamfoneil

    I'm interested in this and taking a look

  2. adamfoneil commented on Apr 29, 2020

    @adamfoneil

    I've been thinking about this some.... Do you have an example of a corrupted settings file? (Is it just empty or full of defaults? Or is it actually mangled, like the serialization was interrupted?) I've seen rare cases where settings files of my own reset mysteriously, but this wasn't using the built-in Settings thing. Some unrelated exception would (I think) reset and new up a fresh form-level instance variable holding my settings, then on app exit, the empty settings object would save. So, in my case, I would end up with empty settings files.

    I'm really not sure how to replicate that fail condition for test purposes, so I was thinking of approaching this by adding "reslience" to a settings architecture. I was thinking about making all Settings property setters write to disk immediately. I would probably have a Settings.Update method that took an Action<T> where the property setter is called. This Update method would call Save implicitly. Then I would consider removing the Settings save call on app exit.

    Another idea I had was making the settings Save method increment a version number on each write, and keep the last 4 settings versions, or something like that. The occasional failures would still happen, but there would be some way in the UI to recover a previous settings version, or maybe recover it silently. I don't think users would understand why they needed to "recover a prior settings version", so I would try to detect on startup when a failure had happened (by noticing an empty settings file) and silently replacing the prior version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions