Skip to content

[stdhl] FileSystem: Fixed race in createDirectory - #13079

Open
TothBenoit wants to merge 1 commit into
HaxeFoundation:developmentfrom
TothBenoit:file-system-fix
Open

TothBenoit wants to merge 1 commit into
HaxeFoundation:developmentfrom
TothBenoit:file-system-fix

Conversation

@TothBenoit

Copy link
Copy Markdown

createDirectory creates each missing part of the path in turn, checking exists(part) and then calling sys_create_dir. If another process creates that same directory between the check and the create, sys_create_dir fails and the function throws. The directory does exist at that point, and the levels below it are never created.

This happens when several processes create overlapping directory trees at the same time, for example parallel asset converters writing under a shared output folder.

The fix: when sys_create_dir fails, check exists(part) again and throw only if the directory still isn't there, the same as mkdir -p.

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.

1 participant