Record if the file was already parsed, ignore them in the generic.
authorGustavo Sverzut Barbieri <gustavo.barbieri@intel.com>
Wed, 12 Feb 2014 14:40:08 +0000 (12:40 -0200)
committerGustavo Sverzut Barbieri <gustavo.barbieri@intel.com>
Wed, 12 Feb 2014 14:40:08 +0000 (12:40 -0200)
Generic parser is more like a fallback, then if the file was already
parsed by some other parser it should ignore that entry.

src/lib/lightmediascanner_plugin.h
src/lib/lightmediascanner_process.c
src/plugins/generic/generic.c

index 4eece6a..41abd62 100644 (file)
@@ -151,6 +151,7 @@ extern "C" {
         time_t dtime; /**< deletion time */
         time_t itime; /**< insert time */
         size_t size; /**< file size in bytes */
+        unsigned char parsed : 1; /**< if file was already successfully parsed before */
     };
 
     struct lms_context {
index 2302303..65a6f84 100644 (file)
@@ -395,6 +395,7 @@ lms_parsers_run(lms_t *lms, sqlite3 *db, void **parser_match, struct lms_file_in
 
     _ctxt_init(&ctxt, lms, db);
 
+    finfo->parsed = 0;
     failed = 0;
     available = 0;
     for (i = 0; i < lms->n_parsers; i++) {
@@ -408,6 +409,8 @@ lms_parsers_run(lms_t *lms, sqlite3 *db, void **parser_match, struct lms_file_in
             r = plugin->parse(plugin, &ctxt, finfo, parser_match[i]);
             if (r != 0)
                 failed++;
+            else
+                finfo->parsed = 1;
         }
     }
 
index e453b67..4be6d60 100644 (file)
@@ -439,6 +439,9 @@ _parse(struct plugin *plugin, struct lms_context *ctxt, const struct lms_file_in
     struct lms_string_size container = { };
     bool video = false;
 
+    if (finfo->parsed)
+        return 0;
+
     if ((ret = avformat_open_input(&fmt_ctx, finfo->path, NULL, NULL)))
         return ret;