Skip to content

Save configuration profiles and gesture maps as an atomic operation (…#5916

Closed
bramd wants to merge 3 commits into
nvaccess:nextfrom
bramd:i3165
Closed

Save configuration profiles and gesture maps as an atomic operation (…#5916
bramd wants to merge 3 commits into
nvaccess:nextfrom
bramd:i3165

Conversation

@bramd

@bramd bramd commented Apr 30, 2016

Copy link
Copy Markdown
Contributor

…refs issue #3165)

Instead of directly writing the file, a temporary file is created and
moved to the final location. This prevents corrupt configuration files
being written.
Added a fileUtils module with just a FaultTolerantFile context manager for
now to facilitate this pattern.
Please update miscDependencies submodule to a revision that includes the
osmove module.

Comment thread source/config/__init__.py Outdated
raise ValueError("A profile with the same name already exists: %s" % newName)

os.rename(oldFn, newFn)
osreplace.replace(oldFn, newFn)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change to osreplace here? In this case, the destination file is not supposed to exist. We should have picked that up above, but it still seems unnecessary... unless I'm missing something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcsteh As I read it, it could be possible this method is called with the same oldName and newName, probably we should check that and just return early instead. Then I agree it's not nescesary as far as I can see.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, after looking at the code again, the "same name" case is clearly handled here. SO, I will use os.rename instead.

bramd added 3 commits June 16, 2016 15:08
…refs issue nvaccess#3165)

Instead of directly writing the file, a temporary file is created and
moved to the final location. This prevents corrupt configuration files
being written.
Added a fileUtils module with just a FaultTolerantFile context manager for
now to facilitate this pattern.
Please update miscDependencies submodule to a revision that includes the
osmove module.
@feerrenrut

Copy link
Copy Markdown
Contributor

Closing this, as it is now superseded by #6987

@feerrenrut feerrenrut closed this Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants