summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-09-27 11:31:29 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-09-27 11:31:29 +0900
commit3be6db09f7994f492723ddc0f5b4b25679fefd41 (patch)
treea6e51c26da5d2490b9d52d56cd5613471df5dca3
parent44b39a8e3ab1e342ad76abfaa8e056eb41867226 (diff)
auto rebuild repo db index on uploads on pkgs
-rw-r--r--mrk-index.c6
-rw-r--r--mrk-srv.c41
2 files changed, 41 insertions, 6 deletions
diff --git a/mrk-index.c b/mrk-index.c
index 7fab73a..00548a1 100644
--- a/mrk-index.c
+++ b/mrk-index.c
@@ -34,7 +34,6 @@ key_register(Eina_Hash *hash, const char *key, const char *entry)
34 const char *ss; 34 const char *ss;
35 Eina_List *entries; 35 Eina_List *entries;
36 36
37 printf("IDX: %p %s -> %s\n", hash, key, entry);
38 ss = eina_stringshare_add(entry); 37 ss = eina_stringshare_add(entry);
39 entries = eina_hash_find(hash, key); 38 entries = eina_hash_find(hash, key);
40 entries = eina_list_sorted_insert(entries, EINA_COMPARE_CB(strcasecmp), ss); 39 entries = eina_list_sorted_insert(entries, EINA_COMPARE_CB(strcasecmp), ss);
@@ -130,12 +129,10 @@ index_file(const char *file, const char *fname)
130 Eina_Hash *ky; 129 Eina_Hash *ky;
131 Eina_Hash *tk; 130 Eina_Hash *tk;
132 131
133 printf("--- %s ---\n", file);
134 ef = eet_open(file, EET_FILE_MODE_READ); 132 ef = eet_open(file, EET_FILE_MODE_READ);
135 if (!ef) return 0; 133 if (!ef) return 0;
136 134
137 ky = key_new(); 135 ky = key_new();
138 printf(".. name\n");
139 s = read_string(ef, "name"); 136 s = read_string(ef, "name");
140 if (s) 137 if (s)
141 { 138 {
@@ -150,7 +147,6 @@ index_file(const char *file, const char *fname)
150 key_free(tk); 147 key_free(tk);
151 free(s); 148 free(s);
152 } 149 }
153 printf(".. tags\n");
154 for (i = 0; i < 9999; i++) 150 for (i = 0; i < 9999; i++)
155 { 151 {
156 tk = key_new(); 152 tk = key_new();
@@ -165,7 +161,6 @@ index_file(const char *file, const char *fname)
165 key_merge(ky, tk); 161 key_merge(ky, tk);
166 key_free(tk); 162 key_free(tk);
167 } 163 }
168 printf(".. categories\n");
169 key_register(db->category_hash, "@", fname); 164 key_register(db->category_hash, "@", fname);
170 for (i = 0; i < 9999; i++) 165 for (i = 0; i < 9999; i++)
171 { 166 {
@@ -182,7 +177,6 @@ index_file(const char *file, const char *fname)
182 key_free(tk); 177 key_free(tk);
183 } 178 }
184 179
185 printf(".. brief\n");
186 s = read_string(ef, "brief"); 180 s = read_string(ef, "brief");
187 if (s) 181 if (s)
188 { 182 {
diff --git a/mrk-srv.c b/mrk-srv.c
index d8f0312..70ee5af 100644
--- a/mrk-srv.c
+++ b/mrk-srv.c
@@ -164,6 +164,34 @@ dbs_clear(void)
164 } 164 }
165} 165}
166 166
167static Ecore_Exe *dbexe = NULL;
168static int db_update = 0;
169
170static void
171dbs_update(void)
172{
173 Eina_List *files;
174 char *s;
175 char tmp[4096];
176
177 if (dbexe)
178 {
179 db_update = 1;
180 return;
181 }
182 snprintf(tmp, sizeof(tmp), "mrk-index %s/*-*", repodir);
183 dbexe = ecore_exe_pipe_run(tmp, 0, NULL);
184 printf("dbs update: run: %s\n", tmp);
185}
186
187static void
188dbs_update_final(void)
189{
190 printf("dbs update final\n");
191 dbs_clear();
192 dbs_load();
193}
194
167static Db * 195static Db *
168dbs_arch_find(const char *arch) 196dbs_arch_find(const char *arch)
169{ 197{
@@ -699,6 +727,19 @@ _exe_cb_del(void *data, int type, void *event)
699 else 727 else
700 ecore_ipc_client_send(c->client, 10, M_UP_FAIL, 0, 0, 0, NULL, 0); 728 ecore_ipc_client_send(c->client, 10, M_UP_FAIL, 0, 0, 0, NULL, 0);
701 c->exe = NULL; 729 c->exe = NULL;
730 dbs_update();
731 }
732 else if (ev->exe == dbexe)
733 {
734 dbexe = NULL;
735 // we had a pending db update - redo it
736 if (db_update)
737 {
738 db_update = 0;
739 dbs_update_final();
740 dbs_update();
741 }
742 else dbs_update_final();
702 } 743 }
703 return EINA_TRUE; 744 return EINA_TRUE;
704} 745}