bug 734624 - java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask.done(AsyncTask.java) caused by: android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed, synchronize inserts to avoid race condition r=lucasr

This commit is contained in:
Brad Lassey 2012-03-16 12:21:06 -04:00
parent 88035a4af3
commit 380a975254

View File

@ -256,12 +256,16 @@ public class Favicons {
// Runs in background thread
private void saveFaviconToDb(BitmapDrawable favicon) {
Log.d(LOGTAG, "Saving favicon on browser database for URL = " + mPageUrl);
ContentResolver resolver = mContext.getContentResolver();
BrowserDB.updateFaviconForUrl(resolver, mPageUrl, favicon);
// since the Async task can run this on any number of threads in the
// pool, we need to protect against inserting the same url twice
synchronized(mDbHelper) {
Log.d(LOGTAG, "Saving favicon on browser database for URL = " + mPageUrl);
ContentResolver resolver = mContext.getContentResolver();
BrowserDB.updateFaviconForUrl(resolver, mPageUrl, favicon);
Log.d(LOGTAG, "Saving favicon URL for URL = " + mPageUrl);
mDbHelper.setFaviconUrlForPageUrl(mPageUrl, mFaviconUrl);
Log.d(LOGTAG, "Saving favicon URL for URL = " + mPageUrl);
mDbHelper.setFaviconUrlForPageUrl(mPageUrl, mFaviconUrl);
}
}
// Runs in background thread