FROM : Ondra Cada
DATE : Wed Nov 20 14:36:19 2002
On Tuesday, Nov 19, 2002, at 20:38 Europe/Prague, Donald Brown wrote:
> Here's the problem with my app, that my customers can run into.
> Person A
> opens file (which reads it all into RAM), Person B opens file (ditto),
> Person A makes changes and saves it, Person B makes changes and saves
> it.
> Person A's changes are thrown away, there is no warning that anything
> is
> wrong. This is bad.
This is how it's *supposed* to be! It's actually the same situation as
if A quit the application before B changed it. Who saved last wins, and
it's completely intuitive, is it not? It would be *quite* crippling if
this was not possible.
Nevertheless, you can easily in your app implement a variant of
optimistic locking: when saving, check whether the contents on disk had
changed from the time you loaded the file in or not (using eg. a MD5
sig, which is easily obtainable via CLI utilities -- man md5). If it
has, issue a warning.
And of course, if you insist and your app's behaviour is such that it
is reasonable, you still *have* the complete sharing API (man 2 open).
But don't use this for generic document handling apps, for they would
behave then a non-standard and quite inconvenient windoze-like way.
Consider eg. an action I do very very often: I open a README from a CD
in TextEdit, and then I unmount the CD, so as I can burn some backup
WHILST reading the document. This is one of *many* possibilities which
would not be possible if programmers used file locking instead of the
proper just-read-it-into-RAM behaviour.
---
Ondra Cada
OCSoftware: <email_removed> http://www.ocs.cz
private <email_removed> http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Wed Nov 20 14:36:19 2002
On Tuesday, Nov 19, 2002, at 20:38 Europe/Prague, Donald Brown wrote:
> Here's the problem with my app, that my customers can run into.
> Person A
> opens file (which reads it all into RAM), Person B opens file (ditto),
> Person A makes changes and saves it, Person B makes changes and saves
> it.
> Person A's changes are thrown away, there is no warning that anything
> is
> wrong. This is bad.
This is how it's *supposed* to be! It's actually the same situation as
if A quit the application before B changed it. Who saved last wins, and
it's completely intuitive, is it not? It would be *quite* crippling if
this was not possible.
Nevertheless, you can easily in your app implement a variant of
optimistic locking: when saving, check whether the contents on disk had
changed from the time you loaded the file in or not (using eg. a MD5
sig, which is easily obtainable via CLI utilities -- man md5). If it
has, issue a warning.
And of course, if you insist and your app's behaviour is such that it
is reasonable, you still *have* the complete sharing API (man 2 open).
But don't use this for generic document handling apps, for they would
behave then a non-standard and quite inconvenient windoze-like way.
Consider eg. an action I do very very often: I open a README from a CD
in TextEdit, and then I unmount the CD, so as I can burn some backup
WHILST reading the document. This is one of *many* possibilities which
would not be possible if programmers used file locking instead of the
proper just-read-it-into-RAM behaviour.
---
Ondra Cada
OCSoftware: <email_removed> http://www.ocs.cz
private <email_removed> http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| Donald Brown | Nov 19, 20:38 | |
| Ondra Cada | Nov 20, 14:36 | |
| Cameron Hayne | Nov 20, 17:08 | |
| Donald Brown | Nov 20, 20:49 | |
| Rosyna | Nov 20, 22:00 | |
| Ondra Cada | Nov 20, 22:19 | |
| Rosyna | Nov 20, 23:25 | |
| Michael Norris | Nov 21, 00:21 | |
| Ondra Cada | Nov 21, 00:29 | |
| Rosyna | Nov 21, 00:31 | |
| Ondra Cada | Nov 21, 00:32 | |
| Malte Tancred | Nov 21, 12:07 | |
| mw | Nov 21, 12:28 | |
| Malte Tancred | Nov 21, 13:47 | |
| Ondra Cada | Nov 21, 14:54 |






Cocoa mail archive

