Move spool file in $PROTO/$GROUP/spool instead of $PROTO/$GROUP
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Mon, 29 Oct 2007 23:04:20 +0000 (23:04 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:35:54 +0000 (00:35 +0100)
This allow having more spool files (For now just feed and spool for each
group, but I plan to split spool in spool and tree_$ROOTNODE).

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@292 9869982d-c50d-0410-be91-f2a2ec7c7c7b

banana/feed.inc.php
banana/spool.inc.php

index 5b6d3d7..451e229 100644 (file)
@@ -9,7 +9,7 @@
 
 require_once dirname(__FILE__) . '/banana.inc.php';
 
-define('BANANA_FEED_VERSION', '0.1');
+define('BANANA_FEED_VERSION', '0.1.1');
 
 class BananaFeed
 {
@@ -36,6 +36,10 @@ class BananaFeed
      */
     public $lastupdate = 0;
 
+    /** Path where the feed is stored
+     */
+    public $path = null;
+
     /** Create an empty feed
      */
     private function __construct()
@@ -105,11 +109,7 @@ class BananaFeed
      */
     static private function filename()
     {
-        $file = Banana::$spool_root . '/' . Banana::$protocole->name() . '/';
-        if (!is_dir($file)) {
-            mkdir($file);
-        }
-        return $file . Banana::$protocole->filename() . '_feed';
+        return BananaSpool::getPath('feed');
     }
 
     /** Read a feed from a cache file
index a96f788..3d44785 100644 (file)
@@ -9,7 +9,7 @@
 
 require_once dirname(__FILE__) . '/banana.inc.php';
 
-define('BANANA_SPOOL_VERSION', '0.5.12');
+define('BANANA_SPOOL_VERSION', '0.5.13');
 
 /** Class spoolhead
  *  class used in thread overviews
@@ -130,19 +130,27 @@ class BananaSpool
         return $spool;
     }
 
-    private static function spoolFilename($group)
+    public static function getPath($file = null)
     {
-        $file = Banana::$spool_root . '/' . Banana::$protocole->name() . '/';
-        if (!is_dir($file)) {
-            mkdir($file);
+        $path = Banana::$spool_root . '/' . Banana::$protocole->name() . '/' . Banana::$protocole->filename();
+        if (!is_dir($path)) {
+            if (file_exists($path)) {
+                @unlink($path);
+            }
+            mkdir($path, 0777, true);
         }
-        return $file . Banana::$protocole->filename();
+        return $path . '/' . $file;
+    }
+
+    private static function spoolFilename()
+    {
+        return BananaSpool::getPath('spool');
     }
 
     private static function &readFromFile($group)
     {
         $spool = null;
-        $file = BananaSpool::spoolFilename($group);
+        $file = BananaSpool::spoolFilename();
         if (!file_exists($file)) {
             return $spool;
         }
@@ -162,7 +170,7 @@ class BananaSpool
 
     private function saveToFile()
     {
-        $file = BananaSpool::spoolFilename($this->group);
+        $file = BananaSpool::spoolFilename();
 
         $this->roots = Array();
         foreach($this->overview as &$msg) {