I have an actix-based API, that operates entirely async. There is one endpoint, that writes a file with a user-given filename on the filesystem (I use async-std library for async fs-operations).
My problem now is, that I run into race-conditions whenever two calls are modifying the same file. I do not want a "global" mutex that locks on each single write, because that would artificially slow down my application for no reason.
Is there a possibility to acquire a lock for each single file, in order that only write-operations for this one specific file are locked & unlocked?