示例#1
0
 /**
  * update node
  * 
  * @param Tinebase_Model_Tree_Node $_node
  * @return Tinebase_Model_Tree_Node
  */
 public function updateNode(Tinebase_Model_Tree_Node $_node)
 {
     $currentNodeObject = $this->_treeNodeBackend->get($_node->getId());
     $modLog = Tinebase_Timemachine_ModificationLog::getInstance();
     $modLog->setRecordMetaData($_node, 'update', $currentNodeObject);
     return $this->_treeNodeBackend->update($_node);
 }
 /**
  * removes deleted files that no longer exist in the filesystem from the database
  * 
  * @return integer number of deleted files
  */
 public function clearDeletedFilesFromDatabase()
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Scanning database for deleted files ...');
     }
     // get all file objects from db and check filesystem existance
     $filter = new Tinebase_Model_Tree_FileObjectFilter();
     $start = 0;
     $limit = 500;
     $toDeleteIds = array();
     do {
         $pagination = new Tinebase_Model_Pagination(array('start' => $start, 'limit' => $limit, 'sort' => 'id'));
         $fileObjects = $this->_fileObjectBackend->search($filter, $pagination);
         foreach ($fileObjects as $fileObject) {
             if ($fileObject->type == Tinebase_Model_Tree_FileObject::TYPE_FILE && $fileObject->hash && !file_exists($fileObject->getFilesystemPath())) {
                 $toDeleteIds[] = $fileObject->getId();
             }
         }
         $start += $limit;
     } while ($fileObjects->count() >= $limit);
     $nodeIdsToDelete = $this->_treeNodeBackend->search(new Tinebase_Model_Tree_Node_Filter(array(array('field' => 'object_id', 'operator' => 'in', 'value' => $toDeleteIds))), NULL, Tinebase_Backend_Sql_Abstract::IDCOL);
     $deleteCount = $this->_treeNodeBackend->delete($nodeIdsToDelete);
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Removed ' . $deleteCount . ' obsolete filenode(s) from the database.');
     }
     return $deleteCount;
 }