diff --git a/lib/classes/task/period/archive.class.php b/lib/classes/task/period/archive.class.php index e0f3a75426..683675039e 100755 --- a/lib/classes/task/period/archive.class.php +++ b/lib/classes/task/period/archive.class.php @@ -176,7 +176,6 @@ class task_period_archive extends task_abstract .copy_spe.checked = copy_spe) ? "true" : "false" ?>;
setLastExecTime(); - try { if ( ! ($this->sxTaskSettings = @simplexml_load_string($this->getSettings()))) { throw new Exception(sprintf('Error fetching or reading settings of the task \'%d\'', $this->getID())); @@ -601,16 +597,17 @@ class task_period_archive extends task_abstract $this->log("=========== archive ========== : \n" . $dom->saveXML()); } - $this->bubbleResults($dom, $root, $path_in); - if ($this->debug) { - $this->log("=========== bubbleResults ========== : \n" . $dom->saveXML()); - } + if ($this->running) { + $this->bubbleResults($dom, $root, $path_in); + if ($this->debug) { + $this->log("=========== bubbleResults ========== : \n" . $dom->saveXML()); + } - $r = $this->moveFiles($dom, $root, $path_in, $path_archived, $path_error); - if ($this->debug) { - $this->log("=========== moveFiles ========== (returned " . ($r ? 'true' : 'false') . ") : \n" . $dom->saveXML()); + $r = $this->moveFiles($dom, $root, $path_in, $path_archived, $path_error); + if ($this->debug) { + $this->log("=========== moveFiles ========== (returned " . ($r ? 'true' : 'false') . ") : \n" . $dom->saveXML()); + } } - if ($this->movedFiles) { // something happened : a least one file has moved @@ -912,7 +909,7 @@ class task_period_archive extends task_abstract $xpath = new DOMXPath($dom); - for ($n = $node->firstChild; $n; $n = $n->nextSibling) { + for ($n = $node->firstChild; $this->running && $n; $n = $n->nextSibling) { if (($iloop ++ % 100) == 0) { usleep(1000); } @@ -1020,7 +1017,7 @@ class task_period_archive extends task_abstract } // scan again for unmatched files - for ($n = $node->firstChild; $n; $n = $n->nextSibling) { + for ($n = $node->firstChild; $this->running && $n; $n = $n->nextSibling) { if ( ! $n->getAttribute('isdir') == '1' && ! $n->getAttribute('match')) { // still no match, now it's an error (bubble to the top) for ($nn = $n; $nn && $nn->nodeType == XML_ELEMENT_NODE; $nn = $nn->parentNode) { @@ -1059,7 +1056,7 @@ class task_period_archive extends task_abstract } $nodesToDel = array(); - for ($n = $node->firstChild; $n; $n = $n->nextSibling) { + for ($n = $node->firstChild; $this->running && $n; $n = $n->nextSibling) { if (($iloop ++ % 20) == 0) { usleep(1000); } @@ -1151,7 +1148,7 @@ class task_period_archive extends task_abstract } $nodesToDel = array(); - for ($n = $node->firstChild; $n; $n = $n->nextSibling) { + for ($n = $node->firstChild; $this->running && $n; $n = $n->nextSibling) { if (($iloop ++ % 20) == 0) { usleep(1000); } @@ -1280,6 +1277,7 @@ class task_period_archive extends task_abstract */ private function moveFiles(\DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, $depth = 0) { + static $iloop = 0; if ($depth == 0) { $iloop = 0; @@ -1749,7 +1747,7 @@ class task_period_archive extends task_abstract private function archiveFilesToGrp(\DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, $grp_rid) { $nodesToDel = array(); - for ($n = $node->firstChild; $n; $n = $n->nextSibling) { + for ($n = $node->firstChild; $this->running && $n; $n = $n->nextSibling) { if ($n->getAttribute('isdir') == '1') { // in a grp, all levels goes in the same grp $node->setAttribute('archived', '1'); // the main grp folder is 'keep'ed, but not subfolders