Closed szh closed 2 years ago
As I've been polishing this code I could not resist taking this into account, hence my attempt at it using option funcs above, based on earlier work in #20. It's the least invasive way I can think of without duplicating code just for testing; if there's a cleaner approach with less effort I'd be interested to know. At least the code to enable the testing code-path is only available during testing, so the risk should be relatively contained as well.
Was actually expecting a suggestion or at least a comment with regard to testing, as that's an interesting aspect. In respect to changing the return type, I wonder if it could stay the same by making AtomicResult comply with the error interface. And then there still is the defer code hanging around which maybe could be removed as a consequence?
We ended up implementing this internally so I'm not going to be able to dedicate time to finishing up the implementation here. If you want to close the PR that's fine with me.
In security sensitive use cases, it would be helpful to allow the caller to know if deleting the temp file failed, so it could retry after a delay, or at least log the failure. My main concern is how to test this functionality.