Conversation

Problem

In utils.filesystem.mkdir, the force argument is intended to enforce directory ownership / mode even if the target path already exists. However, the current implementation calls os.mkdir which raises OSError if the target path exists.

Proposed solution

Mimic Python 3.2+ os.makedirsexist_ok behaviour when creating the leaf.
This is a temporary patch waiting for a migration to Python 3.

Status

Ready for review.

Context

Problem identified in combination with yunohost user ssh add-key called when $HOME/.ssh/authorized_keys doesn't exit but $HOME/.ssh does. The yunohost code correctly calls mkdir with force=True but fails because of the problem addressed by this PR.

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.