X-Git-Url: http://git.roojs.org/?p=pear;a=blobdiff_plain;f=HTML%2FFlexyFramework%2FGenerator.php;fp=HTML%2FFlexyFramework%2FGenerator.php;h=2f8280b1922978eadb738d4d6b5f8e11ea7b45b9;hp=bda57c2598c04c1165a9d236841daf6c96bbd05c;hb=2063745c6b1968da55b28a0a47e0958115e84777;hpb=7e9b31b83d91a9f2935e607a1c4bc0ac344e364d diff --git a/HTML/FlexyFramework/Generator.php b/HTML/FlexyFramework/Generator.php index bda57c25..2f8280b1 100644 --- a/HTML/FlexyFramework/Generator.php +++ b/HTML/FlexyFramework/Generator.php @@ -168,9 +168,10 @@ class HTML_FlexyFramework_Generator extends DB_DataObject_Generator } /** * Generate the cached *.ini and links.ini files (merged for all components) - * + * @param string $iniCacheTmp a temporary file + * @param string $iniCache the real target. */ - static function writeCache($iniCacheTmp, $iniCache) + static function writeCache($iniCacheTmp, $iniCache, $replace = array()) { $fp = fopen($iniCache.".lock", "a+"); @@ -182,14 +183,22 @@ class HTML_FlexyFramework_Generator extends DB_DataObject_Generator //var_dump($iniCacheTmp); // echo '
';echo file_get_contents($iniCacheTmp);exit;
         // only unpdate if nothing went wrong.
+        clearstatcace();
         if (file_exists($iniCacheTmp) && filesize($iniCacheTmp)) {
-            if (file_exists($iniCache)) {
-                unlink($iniCache);
+            // is the replace file exist?
+            if (!isset($replace[$iniCache]) || $replace[$iniCache] != md5_file($iniCacheTmp)) {
+            
+            
+                if (file_exists($iniCache)) {
+                    unlink($iniCache);
+                }
+                $ff->debug("Writing merged ini file : $iniCache\n");
+                rename($iniCacheTmp, $iniCache);
+            } else {
+                touch($iniCache);
             }
-            $ff->debug("Writing merged ini file : $iniCache\n");
-            rename($iniCacheTmp, $iniCache);
         }
-        
+        /*
         // readers..??? not needed??? (historical)
         if (file_exists($iniCacheTmp.'.reader') &&  filesize($iniCacheTmp.'.reader')) {
             if (file_exists($iniCache.'.reader')) {
@@ -198,7 +207,7 @@ class HTML_FlexyFramework_Generator extends DB_DataObject_Generator
             $ff->debug("Writing merged reader file : $iniCache.reader\n");
             rename($iniCacheTmp.'.reader', $iniCache.'.reader');
         }
-        
+        */
         
         // merge and set links.. test for generated links file..
         
@@ -259,13 +268,19 @@ class HTML_FlexyFramework_Generator extends DB_DataObject_Generator
         }
         if (count($out)) {
             $ff->debug("Writing merged Links file : $iniLinksCache \n");
-
-           
-            file_put_contents($iniCacheTmp. '.links.ini', implode("\n", $out));
-            if (file_exists($iniLinksCache)) {                
-                unlink($iniLinksCache);
+            $out_str = implode("\n", $out);
+            // is target file different?
+            if (!isset($replace[$iniLinksCache]) || $replace[$iniLinksCache] != md5($out)) {
+          
+                 file_put_contents($iniCacheTmp. '.links.ini', $out_str);
+                 if (file_exists($iniLinksCache)) {                
+                     unlink($iniLinksCache);
+                 }
+                 rename($iniCacheTmp. '.links.ini', $iniLinksCache);
+            } else {
+                touch($iniLinksCache);
+                
             }
-            rename($iniCacheTmp. '.links.ini', $iniLinksCache);
         }
         
         flock($fp, LOCK_UN);