fixed invalidating artwork info cache for non-existing artwork config file
[rocksndiamonds.git] / src / libgame / setup.c
index 7c864576780e2164c0e50019ff96be61ace4c42e..e1840b1d375e92491492ed31752ecaaf59c07b48 100644 (file)
@@ -96,6 +96,7 @@ static SetupFileHash *artworkinfo_cache_old = NULL;
 static SetupFileHash *artworkinfo_cache_new = NULL;
 static SetupFileHash *optional_tokens_hash = NULL;
 static boolean use_artworkinfo_cache = TRUE;
+static boolean update_artworkinfo_cache = FALSE;
 
 
 // ----------------------------------------------------------------------------
@@ -2972,10 +2973,15 @@ static void LoadArtworkInfoCache(void)
 
   if (artworkinfo_cache_new == NULL)
     artworkinfo_cache_new = newSetupFileHash();
+
+  update_artworkinfo_cache = FALSE;
 }
 
 static void SaveArtworkInfoCache(void)
 {
+  if (!update_artworkinfo_cache)
+    return;
+
   char *filename = getPath2(getCacheDir(), ARTWORKINFO_CACHE_FILE);
 
   InitCacheDirectory();
@@ -3020,6 +3026,9 @@ static boolean modifiedFileTimestamp(char *filename, char *timestamp_string)
   if (timestamp_string == NULL)
     return TRUE;
 
+  if (!fileExists(filename))                   // file does not exist
+    return (atoi(timestamp_string) != 0);
+
   if (stat(filename, &file_status) != 0)       // cannot stat file
     return TRUE;
 
@@ -4000,6 +4009,8 @@ static void LoadArtworkInfoFromLevelInfoExt(ArtworkDirTree **artwork_node,
 
          artwork_new->sort_priority = level_node->sort_priority;
          artwork_new->color = LEVELCOLOR(artwork_new);
+
+         update_artworkinfo_cache = TRUE;
        }
 
        free(path);