示例#1
0
static void
_win_populate_job(void *data)
{
   Win *w = data;
   w->job.populate = NULL;

   if (w->db)
     {
        db_close(w->db);
        w->db = NULL;
     }

   if (access(w->db_path, F_OK|X_OK) == 0)
     w->db = db_open(w->db_path);

   if (!w->db)
     {
        char tmpdir[PATH_MAX];
        lms_t *lms = lms_new(w->db_path);
        if (!lms)
          goto no_lms;
        enjoy_lms_charsets_add(lms);
        if (!enjoy_lms_parsers_add(lms))
          goto no_parsers;

        snprintf(tmpdir, sizeof(tmpdir), "%s/tmpdir-nomusic",
                 enjoy_cache_dir_get());
        ecore_file_mkpath(tmpdir);
        if (lms_process_single_process(lms, tmpdir) != 0)
          CRITICAL("Failed to scan empty directory %s", tmpdir);
        ecore_file_rmdir(tmpdir);
        lms_free(lms);

        w->db = db_open(w->db_path);
        if (!w->db)
          goto no_lms;

        goto populate;

     no_parsers:
        CRITICAL("could not add any lightmediascanner parser!");
        lms_free(lms);
     no_lms:
        CRITICAL("could not create database at %s!", w->db_path);
        exit(-1);
     }

 populate:
   ecore_event_add(ENJOY_EVENT_DB_UNLOCKED, NULL, NULL, NULL);
   list_populate(w->list, w->db);
}
示例#2
0
static int
work(lms_t *lms, int method, int verbose, const char *path)
{
    struct stat st;
    int r;

    if (verbose) {
        lms_set_progress_callback(lms, progress, "CHECK", NULL);
        printf("CHECK at \"%s\" using %s method.\n", path, method_name(method));
    } else
        lms_set_progress_callback(lms, NULL, NULL, NULL);

    if (method == 1)
        r = lms_check_single_process(lms, path);
    else if (method == 2)
        r = lms_check(lms, path);
    else
        r = -1;

    if (r != 0) {
        if (verbose)
            printf("CHECK FAILED at \"%s\".\n", path);
        return r;
    }

    if (stat(path, &st) != 0) {
        printf("PROCESS skipped for '%s': doesn't exist.\n", path);
        return 0;
    }

    if (verbose) {
        lms_set_progress_callback(lms, progress, "PROGRESS", NULL);
        printf("PROCESS at \"%s\" using %s method.\n",
               path, method_name(method));
    } else
        lms_set_progress_callback(lms, NULL, NULL, NULL);

    if (method == 1)
        r = lms_process_single_process(lms, path);
    else if (method == 2)
        r = lms_process(lms, path);

    if (r != 0) {
        if (verbose)
            printf("PROCESS FAILED at \"%s\".\n", path);
        return r;
    }

    return 0;
}