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

Avoid folder naming conflicts with monotonic time and random padding #18

Merged
merged 1 commit into from
Feb 21, 2020

Conversation

zph
Copy link
Contributor

@zph zph commented Sep 4, 2019

👋. Briefly looks like a nice library to use for tempfiles in Elixir!

I wanted to ensure a better promise of not having conflicting folder names (per #16) and I think it's a common user experience to expect that the auto-generated folders will be unique.

To accomplish that end, I switched to using monotonic time (so each erlang vm will be unique in itself) and added cryptographically generated padding.

The switch to using monotonic time and random padding from crypto
to ensure that folders are created uniquely even if created in same moment
by different users or different instances of server.

By adding 20 chars of random padding along with monotonic time, the chance of
collisions is so small as to be negligible.

Further work could add a safety check that it retries folder creation if first one
fails.

Fixes: #16.

If this sounds good, I'm happy to contribute it to the main repo for Briefly 🎉 😸.

Switches to using monotonic time and random padding from crypto
to ensure that folders are created uniquely even if created in same moment by
by different users or different instances of server.

By adding 20 chars of random padding along with monotonic time, the chance of
collisions is so small as to be negligible.

Further work could add a safety check that it retries folder creation if first one
fails.

Fixes: CargoSense#16
@jwarlander
Copy link

I'm happily using this library in production, and haven't yet had a situation where I'd "obviously" run into conflicts, but definitely see this as a useful feature.

@benwilson512 benwilson512 merged commit fdea3e6 into CargoSense:master Feb 21, 2020
@benwilson512
Copy link
Member

Thank you!

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.

Cannot be used by multiple users with default config
3 participants