Open Joy-less opened 1 month ago
I should just mention that since this changes the name of the Mutex, shared mode won't lock correctly if you have two processes where one is using the current or older version of LiteDB and one is using a future LiteDB version.
Super hard to accept prs that are hard to test :/
Super hard to accept prs that are hard to test :/
I don't think so... It's pretty simple. If you like, I can write a test to ensure two connections can still be active at once.
Tbh i am unsure about this change. can we have a setting at userlevel that allows to set a flag for this? (Default this behaviour)
Shared
mode uses a named Mutex to avoid multiple processes reading/writing at the same time. LiteDB names the Mutex to contain the absolute file path of the database. But Mutex names have to be valid file paths, so this would cause an invalid file path like:So instead, currently it hashes the file path using SHA1 to turn it into the following:
However, this is a hacky solution in my opinion. Someone experienced exceptions (#2543) caused when creating SHA1. This PR avoids the need to hash the path by using URL escaping:
Also, I changed it to use
.ToLowerInvariant()
instead of.ToLower()
because Windows file paths are case insensitive even for non-ASCII characters (e.g.É
andé
).This PR should fix #2543 since it removes hashing.