[vlc-devel] [PATCH] modules: bank: Save the cache if it was empty

Hugo Beauzée-Luyssen hugo at beauzee.fr
Wed May 18 20:28:19 CEST 2016


This aims at fixing an issue with some libvlc issues, that wouldn't have
a plugin cache if they don't rely on a VLC player installation (since we
generate the cache upon install time)
---
 src/modules/bank.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/modules/bank.c b/src/modules/bank.c
index 19292e6..4455c94 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -374,11 +374,13 @@ static void AllocatePluginPath (vlc_object_t *p_this, const char *path,
     module_bank_t bank;
     module_cache_t *cache = NULL;
     size_t count = 0;
+    bool b_has_cache = false;
 
     switch( mode )
     {
         case CACHE_USE:
             count = CacheLoad( p_this, path, &cache );
+            b_has_cache = count != 0;
             break;
         case CACHE_RESET:
             CacheDelete( p_this, path );
@@ -410,10 +412,15 @@ static void AllocatePluginPath (vlc_object_t *p_this, const char *path,
                    vlc_module_destroy (cache[i].p_module);
                 free (cache[i].path);
             }
-            free( cache );
-            for (size_t i = 0; i < bank.i_cache; i++)
-                free (bank.cache[i].path);
-            free (bank.cache);
+            if (b_has_cache == false)
+                CacheSave (p_this, path, bank.cache, bank.i_cache);
+            else
+            {
+                free( cache );
+                for (size_t i = 0; i < bank.i_cache; i++)
+                    free (bank.cache[i].path);
+                free (bank.cache);
+            }
             break;
         case CACHE_RESET:
             CacheSave (p_this, path, bank.cache, bank.i_cache);
-- 
2.8.1



More information about the vlc-devel mailing list