add new file system tasks to scheduler
authorPaul Mehrer <p.mehrer@metaways.de>
Thu, 27 Apr 2017 11:02:11 +0000 (13:02 +0200)
committerPaul Mehrer <p.mehrer@metaways.de>
Thu, 27 Apr 2017 12:05:26 +0000 (14:05 +0200)
Change-Id: I7f11c8056d1ff01bd0f226a76b8c7e48a6b5d119
Reviewed-on: http://gerrit.tine20.com/customers/4593
Reviewed-by: Paul Mehrer <p.mehrer@metaways.de>
Tested-by: Paul Mehrer <p.mehrer@metaways.de>
tine20/Tinebase/Frontend/Cli.php
tine20/Tinebase/Scheduler/Task.php
tine20/Tinebase/Setup/Initialize.php
tine20/Tinebase/Setup/Update/Release10.php
tine20/Tinebase/Setup/setup.xml

index 21bc8ff..f3c7c13 100644 (file)
@@ -1147,6 +1147,8 @@ class Tinebase_Frontend_Cli extends Tinebase_Frontend_Cli_Abstract
         }
 
         Tinebase_FileSystem::getInstance()->checkIndexing();
+
+        return 0;
     }
     
     /**
index 03696a9..14c2251 100644 (file)
@@ -376,6 +376,57 @@ class Tinebase_Scheduler_Task extends Zend_Scheduler_Task
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
             . ' Saved task Tinebase_FileSystem::clearFileRevisions in scheduler.');
     }
+
+    /**
+     * add file system index checking task to scheduler
+     *
+     * @param Zend_Scheduler $_scheduler
+     */
+    public static function addFileSystemCheckIndexTask(Zend_Scheduler $_scheduler)
+    {
+        if ($_scheduler->hasTask('Tinebase_FileSystemCheckIndex')) {
+            return;
+        }
+
+        $task = Tinebase_Scheduler_Task::getPreparedTask(Tinebase_Scheduler_Task::TASK_TYPE_DAILY, array(
+            'controller'    => 'Tinebase_FileSystem',
+            'action'        => 'checkIndexing',
+        ));
+
+        $_scheduler->addTask('Tinebase_FileSystemCheckIndex', $task);
+        $_scheduler->saveTask();
+
+        if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
+            . ' Saved task Tinebase_FileSystem::checkIndexing in scheduler.');
+    }
+
+    /**
+     * add file system size recalculation task to scheduler
+     *
+     * @param Zend_Scheduler $_scheduler
+     */
+    public static function addFileSystemSizeRecalculation(Zend_Scheduler $_scheduler)
+    {
+        if ($_scheduler->hasTask('Tinebase_FileSystemSizeRecalculation')) {
+            return;
+        }
+
+        $task = Tinebase_Scheduler_Task::getPreparedTask(Tinebase_Scheduler_Task::TASK_TYPE_DAILY, array(
+            'controller'    => 'Tinebase_FileSystem',
+            'action'        => 'recalculateRevisionSize',
+        ));
+
+        self::addRequestToTask($task, array(
+            'controller'    => 'Tinebase_FileSystem',
+            'action'        => 'recalculateFolderSize',
+        ));
+
+        $_scheduler->addTask('Tinebase_FileSystemSizeRecalculation', $task);
+        $_scheduler->saveTask();
+
+        if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
+            . ' Saved task Tinebase_FileSystem::recalculateRevisionSize and recalculateFolderSize in scheduler.');
+    }
     
     /**
      * run requests
index 1a940e6..5f9a146 100644 (file)
@@ -168,5 +168,7 @@ class Tinebase_Setup_Initialize extends Setup_Initialize
         Tinebase_Scheduler_Task::addAccountSyncTask($scheduler);
         Tinebase_Scheduler_Task::addReplicationTask($scheduler);
         Tinebase_Scheduler_Task::addFileRevisionCleanupTask($scheduler);
+        Tinebase_Scheduler_Task::addFileSystemSizeRecalculation($scheduler);
+        Tinebase_Scheduler_Task::addFileSystemCheckIndexTask($scheduler);
     }
 }
index 0c1150b..8c97e7d 100644 (file)
@@ -934,4 +934,18 @@ class Tinebase_Setup_Update_Release10 extends Setup_Update_Abstract
         $this->setTableVersion('tags', 9);
         $this->setApplicationVersion('Tinebase', '10.20');
     }
+
+    /**
+     * update to 10.21
+     *
+     * add new file system tasks to scheduler
+     */
+    public function update_20()
+    {
+        $scheduler = Tinebase_Core::getScheduler();
+        Tinebase_Scheduler_Task::addFileSystemSizeRecalculation($scheduler);
+        Tinebase_Scheduler_Task::addFileSystemCheckIndexTask($scheduler);
+
+        $this->setApplicationVersion('Tinebase', '10.21');
+    }
 }
index 353d7f0..ebdb0e4 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <application>
     <name>Tinebase</name>
-    <version>10.20</version>
+    <version>10.21</version>
     <tables>
         <table>
             <name>applications</name>