Changeset 16295

Show
Ignore:
Timestamp:
05/02/08 17:28:24 (6 months ago)
Author:
rambo
Message:

minor refactoring to use list_path_items

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/midcom.helper.replicator/queuemanager.php

    r16098 r16295  
    514514    /** 
    515515     * Helper for process_queue, gets items for given queue directory pointer 
    516      */ 
    517     function _process_queue_get_items(&$dp_queue, &$queue_path, &$subscription) 
     516     * @todo use list_path_items ?? 
     517     */ 
     518    function _process_queue_get_items(&$queue_path, &$subscription) 
    518519    { 
    519520        // Start crunching each file into key => XML array 
     
    523524        $items_sort = array(); 
    524525        $GLOBALS['_process_queue_get_items__items_sort'] =& $items_sort; 
    525         while (($queue_item = readdir($dp_queue)) !== false) 
    526         { 
    527             if (   $queue_item == '.' 
    528                 || $queue_item == '..' 
    529                 || $queue_item == 'quarantine') 
    530             { 
    531                 // Skip the . and .. entries (which are always present) & old style quarantine dir 
    532                 continue; 
    533             } 
    534             $item_path = "{$queue_path}/{$queue_item}"; 
     526        $files = $this->list_path_items($queue_path); 
     527        foreach ($files as $item_path) 
     528        { 
     529            $queue_item = basename($item_path); 
    535530            if (   !is_readable($item_path) 
    536531                || !is_file($item_path)) 
     
    607602        $queue_path = "{$subscription_path}/{$queue_name}"; 
    608603 
    609         // Open handle 
    610         $dp_queue = opendir($queue_path); 
    611         if (!$dp_queue) 
    612         { 
    613             debug_add("Cannot open queue path '{$queue_path}' for reading", MIDCOM_LOG_ERROR); 
    614             debug_pop(); 
    615             return; 
    616         } 
    617  
    618604        // Get us the transporter 
    619605        $transporter = midcom_helper_replicator_transporter::create($subscription); 
     
    628614         * TODO: Read only X items to memory at a time ? 
    629615         */ 
    630         $items_ret = $this->_process_queue_get_items($dp_queue, $queue_path, $subscription); 
     616        $items_ret = $this->_process_queue_get_items($queue_path, $subscription); 
    631617        if ($items_ret === false) 
    632618        { 
    633             closedir($dp_queue); 
    634619            debug_add("Fatal error while reading items in {$queue_name}", MIDCOM_LOG_ERROR); 
    635620            debug_pop(); 
     
    638623        $items =& $items_ret[0]; 
    639624        $items_paths =& $items_ret[1]; 
    640  
    641         closedir($dp_queue); 
    642625 
    643626        if (!$transporter->process($items))