Rework db insertion code
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_certinfo.c
index 7535c93..c626b51 100644 (file)
@@ -603,6 +603,8 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha
                return PMINFO_R_EINVAL;
        }
 
+       _check_create_cert_db();
+
        /* open unified global cert db */
        dbpath = getUserPkgCertDBPathUID(GLOBAL_USER);
        if (dbpath == NULL)
@@ -623,8 +625,6 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha
                return PMINFO_R_ERROR;
        }
 
-       _check_create_cert_db(db);
-
        if (_pkginfo_save_cert_index_info(db, info->cert_info)) {
                _LOGE("failed to save cert index info, rollback now");
                sqlite3_exec(GET_DB(cert_db), "ROLLBACK", NULL, NULL, NULL);