| Thumbnail Managing Standard | ||
|---|---|---|
| <<< Previous | Next >>> | |
If multiple programs are using the same directory hierarchy for reading and writing information its likely that they conflict with each other. Possible conflicts are:
Two programs try to write the same thumbnail.
A program tries to read a thumbnail which is not completely written by another program yet.
To avoid this, every program must try to get a lock on a thumbnail size directory first before accessing any files in it. This is done via a simple file based locking mechanism. A .lock file which contains a pid (process id) indicates that the program with this pid is allowed to read/write files. If a program finds a .lock file which it doesn't own it must wait until it disappears and can then create a lock by itself. Of course the program must remove the lock file if it has read/written all thumbnails.
The lock is always for a certain thumbnail size directory. So if two programs access different thumbnail size directories they don't hinder themselves.
Example 3. Lock directory
A program wants to check for a large thumbnail of a file. The first step is to look if there exists a .lock file in the ~/.thumbnails/128x128 directory already. If it does you have to wait here. Otherwise create the file ~/.thumbnails/128x128/.lock with your actual pid as content.
| <<< Previous | Home | Next >>> |
| Deleting Thumbnails | Conclusion |