Skip to content

Commit

Permalink
Minor crawler maintenance
Browse files Browse the repository at this point in the history
1. Use dt_imgid_t instead of int and NO_IMGID where appropriate
2. NULL is better than FALSE if we talk about a pointer
  • Loading branch information
jenshannoschwalm authored and TurboGit committed Nov 21, 2024
1 parent 15e733a commit e079290
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
{
if(dt_conf_get_bool("run_crawler_on_start") && !darktable.gimp.mode)
{
darktable_splash_screen_create(FALSE,TRUE); // force the splash screen for the crawl even if user-disabled
darktable_splash_screen_create(NULL, TRUE); // force the splash screen for the crawl even if user-disabled
// scan for cases where the database and xmp files have different timestamps
changed_xmp_files = dt_control_crawler_run();
}
Expand Down
19 changes: 10 additions & 9 deletions src/control/crawler.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ GList *dt_control_crawler_run(void)
{
sqlite3_stmt *stmt, *inner_stmt;
GList *result = NULL;
gboolean look_for_xmp = (dt_image_get_xmp_mode() != DT_WRITE_XMP_NEVER);
const gboolean look_for_xmp = dt_image_get_xmp_mode() != DT_WRITE_XMP_NEVER;

int total_images = 1;
// clang-format off
Expand Down Expand Up @@ -383,7 +383,7 @@ static void _select_invert_callback(GtkButton *button, gpointer user_data)
}


static void _db_update_timestamp(const int id, const time_t timestamp)
static void _db_update_timestamp(const dt_imgid_t id, const time_t timestamp)
{
// Update DB writing timestamp with XMP file timestamp
sqlite3_stmt *stmt;
Expand All @@ -408,7 +408,8 @@ static void _get_crawler_entry_from_model(GtkTreeModel *model,
DT_CONTROL_CRAWLER_COL_ID, &entry->id,
DT_CONTROL_CRAWLER_COL_XMP_PATH, &entry->xmp_path,
DT_CONTROL_CRAWLER_COL_TS_DB_INT, &entry->timestamp_db,
DT_CONTROL_CRAWLER_COL_TS_XMP_INT, &entry->timestamp_xmp, -1);
DT_CONTROL_CRAWLER_COL_TS_XMP_INT, &entry->timestamp_xmp,
-1); // marks list end
}


Expand Down Expand Up @@ -445,7 +446,7 @@ static void sync_xmp_to_db(GtkTreeModel *model,
gpointer user_data)
{
dt_control_crawler_gui_t *gui = (dt_control_crawler_gui_t *)user_data;
dt_control_crawler_result_t entry = { 0 };
dt_control_crawler_result_t entry = { NO_IMGID };
_get_crawler_entry_from_model(model, iter, &entry);
_db_update_timestamp(entry.id, entry.timestamp_xmp);

Expand Down Expand Up @@ -474,7 +475,7 @@ static void sync_db_to_xmp(GtkTreeModel *model,
gpointer user_data)
{
dt_control_crawler_gui_t *gui = (dt_control_crawler_gui_t *)user_data;
dt_control_crawler_result_t entry = { 0 };
dt_control_crawler_result_t entry = { NO_IMGID };
_get_crawler_entry_from_model(model, iter, &entry);

// write the XMP and make sure it get the last modified timestamp of the db
Expand Down Expand Up @@ -503,7 +504,7 @@ static void sync_newest_to_oldest(GtkTreeModel *model,
gpointer user_data)
{
dt_control_crawler_gui_t *gui = (dt_control_crawler_gui_t *)user_data;
dt_control_crawler_result_t entry = { 0 };
dt_control_crawler_result_t entry = { NO_IMGID };
_get_crawler_entry_from_model(model, iter, &entry);

gboolean error = FALSE;
Expand Down Expand Up @@ -574,7 +575,7 @@ static void sync_oldest_to_newest(GtkTreeModel *model,
gpointer user_data)
{
dt_control_crawler_gui_t *gui = (dt_control_crawler_gui_t *)user_data;
dt_control_crawler_result_t entry = { 0 };
dt_control_crawler_result_t entry = { NO_IMGID };
_get_crawler_entry_from_model(model, iter, &entry);
gboolean error = FALSE;

Expand Down Expand Up @@ -903,8 +904,8 @@ static inline gboolean _still_thumbing(void)
}

static void _update_img_thumbs(const dt_imgid_t imgid,
const dt_mipmap_size_t max_mip,
const int64_t stamp)
const dt_mipmap_size_t max_mip,
const int64_t stamp)
{
for(dt_mipmap_size_t k = max_mip; k >= DT_MIPMAP_1; k--)
{
Expand Down

0 comments on commit e079290

Please sign in to comment.