Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Clear CDMA data as well

  • Loading branch information...
commit 9964b4dce4ff4b342d4421ff6a7024a8db9274cd 1 parent 045b223
@rpetrich authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 untrackerd.c
View
37 untrackerd.c
@@ -93,6 +93,43 @@ static inline bool clear_data()
sqlite3_finalize(statement);
if (!sqlite_is_success(result))
goto close;
+ // Clear CDMA data if necessary
+ result = sqlite3_prepare_v2(database, "SELECT count(*) FROM sqlite_master WHERE type='table' AND name='CdmaCellLocation';", -1, &statement, NULL);
+ if (!sqlite_is_success(result))
+ goto close;
+ int has_cdma = 0;
+ while ((result = sqlite3_step(statement)) == SQLITE_ROW) {
+ has_cdma = sqlite3_column_int(statement, 0);
+ }
+ sqlite3_finalize(statement);
+ if (has_cdma != 0) {
+ // Clear CDMA Cell data
+ result = sqlite3_prepare_v2(database, "DELETE FROM CdmaCellLocation WHERE Timestamp < ?;", -1, &statement, NULL);
+ if (!sqlite_is_success(result))
+ goto close;
+ result = sqlite3_bind_double(statement, 1, time);
+ if (sqlite_is_success(result)) {
+ do {
+ result = sqlite3_step(statement);
+ } while (result == SQLITE_ROW);
+ }
+ sqlite3_finalize(statement);
+ if (!sqlite_is_success(result))
+ goto close;
+ // Clear Local CDMA Cell data
+ result = sqlite3_prepare_v2(database, "DELETE FROM CdmaCellLocationLocal WHERE Timestamp < ?;", -1, &statement, NULL);
+ if (!sqlite_is_success(result))
+ goto close;
+ result = sqlite3_bind_double(statement, 1, time);
+ if (sqlite_is_success(result)) {
+ do {
+ result = sqlite3_step(statement);
+ } while (result == SQLITE_ROW);
+ }
+ sqlite3_finalize(statement);
+ if (!sqlite_is_success(result))
+ goto close;
+ }
// Apply vacuuming if necessary
result = sqlite3_prepare_v2(database, "PRAGMA auto_vacuum;", -1, &statement, NULL);
if (!sqlite_is_success(result))
Please sign in to comment.
Something went wrong with that request. Please try again.