Skip to content

Commit

Permalink
handle missing domain colum in fetcher cache
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Sep 10, 2024
1 parent 03535d0 commit eebce6c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/libfetchers/cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ struct CacheImpl : Cache

state->db = SQLite(dbPath);
state->db.isCache();

// Check if the 'domain' column exists in the 'Cache' table
SQLiteStmt pragmaStmt(state->db, "pragma table_info(Cache)");
bool domainColumnExists = false;
while (pragmaStmt.next()) {
std::string columnName = pragmaStmt.getStr(1);
if (columnName == "domain") {
domainColumnExists = true;
break;
}
}

// If 'domain' column does not exist, drop the 'Cache' table
if (!domainColumnExists) {
state->db.exec("drop table if exists Cache");
}
state->db.exec(schema);

state->upsert.create(state->db,
Expand Down

0 comments on commit eebce6c

Please sign in to comment.