Save configuration profiles and gesture maps as an atomic operation (…#5916
Closed
bramd wants to merge 3 commits into
Closed
Save configuration profiles and gesture maps as an atomic operation (…#5916bramd wants to merge 3 commits into
bramd wants to merge 3 commits into
Conversation
| raise ValueError("A profile with the same name already exists: %s" % newName) | ||
|
|
||
| os.rename(oldFn, newFn) | ||
| osreplace.replace(oldFn, newFn) |
Contributor
There was a problem hiding this comment.
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?
Contributor
Author
There was a problem hiding this comment.
@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.
Contributor
Author
There was a problem hiding this comment.
Hmm, after looking at the code again, the "same name" case is clearly handled here. SO, I will use os.rename instead.
…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.
Merged
Contributor
|
Closing this, as it is now superseded by #6987 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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.