Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure CreateTempDir() is Multi-Process Safe #246

Merged
merged 6 commits into from
Apr 7, 2024

Conversation

noyshabtay
Copy link
Contributor

@noyshabtay noyshabtay commented Apr 7, 2024

  • All tests passed. If this feature is not already covered by the tests, I added new tests.
  • All static analysis checks passed.
  • This pull request is on the dev branch.
  • I used gofmt for formatting the code before submitting the pull request.

Refining CreateTempDir() by appending a wildcard * at the end of the MkdirTemp() pattern argument. This ensures that a unique random string replaces the last *, preventing concurrent processes or goroutines from selecting the same directory. This approach is preferred over using only strconv.FormatInt(time.Now().Unix(), 10), which may not offer sufficient distinction between processes.

@noyshabtay noyshabtay added the bug Something isn't working label Apr 7, 2024
@noyshabtay noyshabtay self-assigned this Apr 7, 2024
@noyshabtay noyshabtay requested a review from omerzi April 7, 2024 13:31
@noyshabtay noyshabtay changed the title 🐛 multi-process safe CreateTempDir Multi-process safe CreateTempDir Apr 7, 2024
@noyshabtay noyshabtay changed the title Multi-process safe CreateTempDir Make CreateTempDir multi-process safe Apr 7, 2024
@noyshabtay noyshabtay changed the title Make CreateTempDir multi-process safe Make CreateTempDir() multi-process safe Apr 7, 2024
@noyshabtay noyshabtay marked this pull request as ready for review April 7, 2024 14:12
@noyshabtay noyshabtay changed the title Make CreateTempDir() multi-process safe Ensure CreateTempDir() is Multi-Process Safe Apr 7, 2024
utils/fileutils_test.go Outdated Show resolved Hide resolved
@noyshabtay noyshabtay merged commit a7235a5 into dev Apr 7, 2024
25 of 26 checks passed
@noyshabtay noyshabtay deleted the process-safe-CreateTempDir branch April 7, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants