return 0;
}
+#ifdef TIZEN_PROFILE_TV
+static bool need_to_remove = false;
+static int __integrity_callback(void *pid, int argc, char **argv, char **notUsed2)
+{
+ CAL_FN_CALL();
+
+ if (NULL == argv || NULL == argv[0]) {
+ ERR("Invalid parameter");
+ need_to_remove = true;
+ return -1;
+ }
+
+ if (0 != strcmp(argv[0], "ok")) {
+ ERR("integrity_check() Fail(argv[%s])", argv[0]);
+ need_to_remove = true;
+ return -1;
+ }
+
+ DBG("integrity_check done");
+ return 0;
+}
+
+void __integrity_check(void)
+{
+ CAL_FN_CALL();
+
+ int ret = 0;
+ sqlite3 *db = NULL;
+
+ ret = db_util_open(CAL_DB_FILE, &db, 0);
+ if (SQLITE_CORRUPT == ret) {
+ ERR("db_util_open() Fail(%d)", ret);
+ need_to_remove = true;
+ }
+
+ ret = sqlite3_exec(db, "pragma integrity_check", __integrity_callback, NULL, NULL);
+ db_util_close(db);
+
+ if (true == need_to_remove || SQLITE_CORRUPT == ret || SQLITE_NOTADB == ret) {
+ ERR("need_to_remove(%d)", ret);
+ remove(CAL_DB_SHM_FILE);
+ remove(CAL_DB_WAL_FILE);
+ remove(CAL_DB_FILE);
+ need_to_remove = false;
+ }
+}
+
+#endif
+
static inline int __check_db_file(void)
{
int fd = -1;
int cal_server_schema_check(void)
{
+#ifdef TIZEN_PROFILE_TV
+ __integrity_check();
+#endif
+
if (__check_db_file())
__remake_db_file();
return 0;
#define TZ_DATA_PATH tzplatform_getenv(TZ_USER_DATA)
#define CAL_DATA_PATH tzplatform_mkpath(TZ_USER_DATA, "calendar-service")
#define CAL_DB_FILE tzplatform_mkpath(TZ_USER_DB, "privacy/.calendar-service.db")
+#define CAL_DB_SHM_FILE tzplatform_mkpath(TZ_USER_DB, "privacy/.calendar-service.db-shm")
+#define CAL_DB_WAL_FILE tzplatform_mkpath(TZ_USER_DB, "privacy/.calendar-service.db-wal")
/* For Security */
#define CAL_SECURITY_FILE_GROUP 5000