#include <glib.h>
Go to the source code of this file.
Typedefs | |
typedef unsigned long long | u_int64_t |
Functions | |
G_BEGIN_DECLS gboolean | index_full (gchar *dir, gboolean skip_thumbnails) |
u_int64_t | getCurrentTime () |
void | store_metadata_ready () |
Handle next documents. |
u_int64_t getCurrentTime | ( | ) |
Definition at line 64 of file index.c.
Referenced by index_full(), main(), on_message_timeout(), and schedule_update().
00065 { 00066 struct timespec now; 00067 00068 clock_gettime(CLOCK_MONOTONIC, &now); 00069 u_int64_t now64 = now.tv_sec; 00070 now64 *= 1000000; 00071 now64 += (now.tv_nsec/1000); 00072 return now64; 00073 }
G_BEGIN_DECLS gboolean index_full | ( | gchar * | dir, | |
gboolean | skip_thumbnails | |||
) |
File Name : index.h Copyright (C) 2009 iRex Technologies B.V. All rights reserved.
Definition at line 525 of file index.c.
References ade_thumbs_dir, db_close(), db_get_model(), db_open_global(), DIR_ADE_THUMBS, DIR_DRZ, DIR_SHORTCUTS, drz_dir, ER_OK, ERRORPRINTF, filetypes_init(), getCurrentTime(), handle_changes(), LOGPRINTF, read_directory(), shortcut_dir, startdir, startdirlen, and WARNPRINTF.
Referenced by main().
00526 { 00527 int len = strlen(dir); 00528 // strip off trailing slash 00529 if (len>0 && dir[len-1] == '/') dir[len-1] = '\0'; 00530 strncpy(startdir, dir, sizeof(startdir)); 00531 startdir[sizeof(startdir)-1] = '\0'; 00532 startdirlen = strlen(startdir); 00533 00534 // check if dir exists and is dir 00535 struct stat statbuf; 00536 int res = stat(dir, &statbuf); 00537 if (res == -1 || !S_ISDIR(statbuf.st_mode)) { 00538 fprintf(stderr, "mdbindex: directory '%s' doesn't exist or is not a dir\n", dir); 00539 return FALSE; 00540 } 00541 00542 // init static dirs with startdir pre-fix 00543 sprintf(drz_dir, "%s/%s", startdir, DIR_DRZ); 00544 sprintf(shortcut_dir, "%s/%s", startdir, DIR_SHORTCUTS); 00545 sprintf(ade_thumbs_dir, "%s/%s", startdir, DIR_ADE_THUMBS); 00546 00547 db_state_t db_state; 00548 if (db_open_global(&db_state, dir) != ER_OK) 00549 { 00550 ERRORPRINTF("Failed to open global db"); 00551 return FALSE; 00552 } 00553 db_close(&db_state); 00554 00555 filetypes_init(FALSE); 00556 00557 // read database model 00558 u_int64_t t1 = getCurrentTime(); 00559 GSList* db_model = db_get_model(dir); 00560 if (db_model == NULL) WARNPRINTF("DB is empty"); 00561 u_int64_t t2 = getCurrentTime(); 00562 u_int64_t diff = t2 - t1; 00563 LOGPRINTF("DB DURATION = %lld ms", diff / 1000); 00564 00565 // read fs and mark changes 00566 t1 = getCurrentTime(); 00567 read_directory(dir, &db_model); 00568 t2 = getCurrentTime(); 00569 diff = t2 - t1; 00570 LOGPRINTF("FS/COMPARE DURATION = %lld ms", diff / 1000); 00571 00572 // update database with changed entries 00573 t1 = getCurrentTime(); 00574 gboolean changed = handle_changes(db_model, dir, skip_thumbnails); 00575 t2 = getCurrentTime(); 00576 diff = t2 - t1; 00577 LOGPRINTF("DB UPDATE DURATION = %lld ms", diff / 1000); 00578 00579 // NOTE: not freeing db_model for speed 00580 return changed; 00581 }
void store_metadata_ready | ( | ) |
Handle next documents.
Definition at line 505 of file index.c.
References g_iter, ignore_thumbnail_generation(), and send_store_metadata().
Referenced by on_storemetadata_ready().
00506 { 00507 g_iter = g_slist_next(g_iter); 00508 00509 while (g_iter) { 00510 db_entry_t* db_entry = g_iter->data; 00511 00512 if (!ignore_thumbnail_generation(db_entry)) 00513 { 00514 if (send_store_metadata(db_entry)) 00515 { 00516 return; 00517 } 00518 } 00519 g_iter = g_slist_next(g_iter); 00520 } 00521 gtk_main_quit(); 00522 }