Enlightenment CVS committal Author : chaos Project : e17 Module : apps/evfs
Dir : e17/apps/evfs/src/bin Modified Files: evfs_metadata.c evfs_metadata_db.c Log Message: Ok - be careful - this *will* start to harvest metadata in your homedir. Things to note: * Hardcoded to harvest ".mp3", ".mpg", and ".jpg" (for now). * Will only harvest your homedirectory. * The DB (~/.e/evfs/evfs_metadata.db) should not grow *too* large - 2000 harvested files == ~1mb =================================================================== RCS file: /cvs/e/e17/apps/evfs/src/bin/evfs_metadata.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- evfs_metadata.c 5 Aug 2006 12:25:10 -0000 1.26 +++ evfs_metadata.c 6 Aug 2006 04:29:22 -0000 1.27 @@ -385,13 +385,13 @@ /*Setup the directory scan queue*/ ref = NEW(evfs_filereference); ref->plugin_uri = strdup("file"); - ref->path = homedir; + ref->path = strdup(homedir); evfs_metadata_directory_scan_queue = ecore_list_new(); ecore_list_append(evfs_metadata_directory_scan_queue, ref); - ecore_timer_add(1.0, evfs_metadata_scan_runner, NULL); - ecore_timer_add(1.0, evfs_metadata_extract_runner, NULL); + ecore_timer_add(0.5, evfs_metadata_scan_runner, NULL); + ecore_timer_add(0.5, evfs_metadata_extract_runner, NULL); } } @@ -675,26 +675,51 @@ int evfs_metadata_scan_runner(void* data) { evfs_filereference* ref; + evfs_filereference* iref; + char tmp[PATH_MAX]; if ((ref = ecore_list_remove_first( evfs_metadata_directory_scan_queue))) { evfs_filereference_sanitise(ref); - printf("Scanning %s://%s..\n", ref->plugin_uri, ref->path); - if (ref->plugin) { Ecore_List* dir_list; - evfs_command* c = NEW(evfs_command); - c->file_command.files = calloc(1, sizeof(evfs_filereference*)); - c->file_command.files[0] = ref; - c->file_command.num_files = 1; + evfs_command* c = evfs_file_command_single_build(ref); (*EVFS_PLUGIN_FILE(ref->plugin)->functions->evfs_dir_list) (NULL, c, &dir_list); evfs_cleanup_file_command(c); - printf("List returned: %d\n", ecore_list_nodes(dir_list)); + ecore_list_goto_first(dir_list); + while ( (iref = ecore_list_remove_first(dir_list))) { + struct stat file_stat; + char* pos = strrchr(iref->path, '/'); + + if (pos) { + /*Dangerous - check str length TODO*/ + /*Are we a hidden dir/file?*/ + if (!(pos[1] == '.')) { + evfs_command* ci = evfs_file_command_single_build(iref); + (*EVFS_PLUGIN_FILE(iref->plugin)->functions->evfs_file_lstat) + (ci, &file_stat, 0); + + if (S_ISDIR(file_stat.st_mode)) { + ecore_list_append(evfs_metadata_directory_scan_queue, iref); + free(ci->file_command.files); + free(ci); + } else if (strstr(iref->path, ".mp3") || strstr(iref->path, ".jpg") || + strstr(iref->path, ".mpg")) { + ecore_list_append(evfs_metadata_queue, iref); + free(ci->file_command.files); + free(ci); + } else { + evfs_cleanup_file_command(ci); + } + } + } + } + ecore_list_destroy(dir_list); } else { evfs_cleanup_filereference(ref); } =================================================================== RCS file: /cvs/e/e17/apps/evfs/src/bin/evfs_metadata_db.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- evfs_metadata_db.c 23 Jul 2006 04:49:42 -0000 1.6 +++ evfs_metadata_db.c 6 Aug 2006 04:29:22 -0000 1.7 @@ -263,30 +263,46 @@ /*printf("File path is: %s\n", file_path);*/ - snprintf(query, sizeof(query), "select id from File where filename ='%s'", file_path); + snprintf(query, sizeof(query), "select id from File where filename = ?"); ret = sqlite3_prepare(db, query, -1, &pStmt, 0); if (ret == SQLITE_OK) { + sqlite3_bind_text(pStmt, 1, file_path, strlen(file_path), SQLITE_STATIC); + ret = sqlite3_step(pStmt); if (ret == SQLITE_ROW) { file = sqlite3_column_int(pStmt,0); + + sqlite3_reset(pStmt); + sqlite3_finalize(pStmt); } else { + sqlite3_reset(pStmt); + sqlite3_finalize(pStmt); + if (create) { - snprintf(query, sizeof(query), "insert into File (filename) select '%s';", file_path); - ret = sqlite3_exec(db, query, - NULL, 0,&errMsg); - - file = (int)sqlite3_last_insert_rowid(db); + snprintf(query, sizeof(query), "insert into File (filename) values(?);"); + ret = sqlite3_prepare(db, query, -1, &pStmt, 0); + sqlite3_bind_text(pStmt, 1, file_path, strlen(file_path), SQLITE_STATIC); + + if (sqlite3_step(pStmt) == SQLITE_DONE) { + file = (int)sqlite3_last_insert_rowid(db); + } else { + file = 0; + } + + sqlite3_reset(pStmt); + sqlite3_finalize(pStmt); } else { file = 0; } } } else { - printf("id_for_file: sqlite error\n"); + sqlite3_reset(pStmt); + sqlite3_finalize(pStmt); + + printf("id_for_file: sqlite error (%s)\n", file_path); file = 0; } - sqlite3_reset(pStmt); - sqlite3_finalize(pStmt); return file; } ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs