auto rebuild repo db index on uploads on pkgs

This commit is contained in:
Carsten Haitzler 2014-09-27 11:31:29 +09:00
parent 44b39a8e3a
commit 3be6db09f7
2 changed files with 41 additions and 6 deletions

View File

@ -34,7 +34,6 @@ key_register(Eina_Hash *hash, const char *key, const char *entry)
const char *ss;
Eina_List *entries;
printf("IDX: %p %s -> %s\n", hash, key, entry);
ss = eina_stringshare_add(entry);
entries = eina_hash_find(hash, key);
entries = eina_list_sorted_insert(entries, EINA_COMPARE_CB(strcasecmp), ss);
@ -130,12 +129,10 @@ index_file(const char *file, const char *fname)
Eina_Hash *ky;
Eina_Hash *tk;
printf("--- %s ---\n", file);
ef = eet_open(file, EET_FILE_MODE_READ);
if (!ef) return 0;
ky = key_new();
printf(".. name\n");
s = read_string(ef, "name");
if (s)
{
@ -150,7 +147,6 @@ index_file(const char *file, const char *fname)
key_free(tk);
free(s);
}
printf(".. tags\n");
for (i = 0; i < 9999; i++)
{
tk = key_new();
@ -165,7 +161,6 @@ index_file(const char *file, const char *fname)
key_merge(ky, tk);
key_free(tk);
}
printf(".. categories\n");
key_register(db->category_hash, "@", fname);
for (i = 0; i < 9999; i++)
{
@ -182,7 +177,6 @@ index_file(const char *file, const char *fname)
key_free(tk);
}
printf(".. brief\n");
s = read_string(ef, "brief");
if (s)
{

View File

@ -164,6 +164,34 @@ dbs_clear(void)
}
}
static Ecore_Exe *dbexe = NULL;
static int db_update = 0;
static void
dbs_update(void)
{
Eina_List *files;
char *s;
char tmp[4096];
if (dbexe)
{
db_update = 1;
return;
}
snprintf(tmp, sizeof(tmp), "mrk-index %s/*-*", repodir);
dbexe = ecore_exe_pipe_run(tmp, 0, NULL);
printf("dbs update: run: %s\n", tmp);
}
static void
dbs_update_final(void)
{
printf("dbs update final\n");
dbs_clear();
dbs_load();
}
static Db *
dbs_arch_find(const char *arch)
{
@ -699,6 +727,19 @@ _exe_cb_del(void *data, int type, void *event)
else
ecore_ipc_client_send(c->client, 10, M_UP_FAIL, 0, 0, 0, NULL, 0);
c->exe = NULL;
dbs_update();
}
else if (ev->exe == dbexe)
{
dbexe = NULL;
// we had a pending db update - redo it
if (db_update)
{
db_update = 0;
dbs_update_final();
dbs_update();
}
else dbs_update_final();
}
return EINA_TRUE;
}