Summary:
As of now, the contributions table uses autogenerated id as the primary key. So every time the app is started, the DB is flushed and populated again.
This can be avoided if pageid returned by the imageinfo API is used as the primary key.
For images currently being uploaded, we would need to use a locally generated key and then replace it once the upload succeeds.