Closed forslund closed 3 years ago
why not create the paths instead? ensures uniqueness and seems to be what the user intended
bad characters are also an issue, but is that something we should solve or "blame the user" and fail loudly?
not saying i oppose this change, it makes a lot of sense to me, just considering alternatives
Creating the paths could be quite elegant as well. The thing against it I can think of is handling of ..
and .
in the path. A name ../myLock
would be created outside of the detected ram-disk folder and we can't know if there is write access...
why not create the paths instead? ensures uniqueness and seems to be what the user intended
bad characters are also an issue, but is that something we should solve or "blame the user" and fail loudly?
not saying i oppose this change, it makes a lot of sense to me, just considering alternatives
I like that the hashing is essentially a one-line change; the path would still require filtering invalid characters which could cause name conflicts with any attempt at static substitution... This could be changed to Base64 encoding instead of hashing if there was reason to get the original name out of the final path..
Hmm base64 is probably the better choice here. Will change the PR to that using "Base 64 Encoding with URL and Filename Safe Alphabet" which should be altchars='-_'
This will allow strings with weird characters, including paths to be used as names for NamedLock instances. Implementation uses the sha1 hex-digest of the name as filename. Resolves #5