Same file or changed?
Currently, I am playing around with a web service, which - on request - reads a file and sends back an object representing the contents of the file.
The consumer-side recieves the object and possibly make changes to it and post it back, where it is stored/updated in the same file.
However, I want some mechanism, which check if it is actually the same file as when it was requested in the first place. Some other person might have changed it while it was being edited. If that is the case it should not be updated, but the user should be made aware of the fault.
I have thought about several options, but I not sure what the best practice is. Here is what I though...
- Checksum, calculate when requested send it together with the object and check when the changes are submitted. I do not want to implement all kinds of algorithms, so what are my options i C#, if this is the best way?
- Reading the file properties and instead of sending the checksum with the object, then send the time it was last changed. Is this a possible solution?
Thanks a lot, Jacob.
|