| ▲ | what an hour ago | |||||||
This seems really silly to me. Why does get_owner need to differentiate between the document exists and maybe has an owner or the document doesn’t exist and thus has no owner. In both cases getting no owner should suffice? Why are you using get_owner to try and figure out if the document exists? Can you give an example where this distinction actually matters? | ||||||||
| ▲ | aw1621107 an hour ago | parent [-] | |||||||
> In both cases getting no owner should suffice? Depends on what exactly you plan on doing with the information, I'd imagine. I don't think it's necessarily a given that "no document" and "no owner" should be handled identically (e.g., searching for the updated document to try again vs. returning an operation-not-allowed error). > Why are you using get_owner to try and figure out if the document exists? Potential TOCTOU issues, perhaps? As I mentioned the document could have vanished out from under you so detecting this situation could let handle things appropriately (though to be fair that argument could probably extend to future operations as well). Maybe a versioned filesystem would have made a bit more sense, where None would indicate a new version is available? Another example I've seen mentioned is trying to get a key-value pair from a JSON where the key may be missing. But in any case, I did say it was a bit of a contrived example, so cut me a bit of slack :P It was just the first thing that came to mind. The examples sibling comments give are probably more practical. | ||||||||
| ||||||||