I may be missing something, but the way the Database class copies the database around doesn't seem at all threadsafe to me. What happens in the following situation:
- Thread A copies database to temporary location A and makes some changes
- Thread B copies database to temporary location B and makes some changes
- Thread A copies database back to the device
- Thread B copies database back to the device
The changes thread A made would be lost. Or is there something in the architecture of Calibre that prevents this situation from happening?