mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-12 04:31:32 +00:00
add a new task for checking the checksum of all versions
This commit is contained in:
parent
599786bcb0
commit
a7286be63a
|
@ -23,7 +23,7 @@ class SeedDMS_ExpiredDocumentsTask extends SeedDMS_SchedulerTaskBase { /* {{{ */
|
||||||
$taskparams = $task->getParameter();
|
$taskparams = $task->getParameter();
|
||||||
$docs = $dms->getDocumentsExpired(intval($taskparams['days']));
|
$docs = $dms->getDocumentsExpired(intval($taskparams['days']));
|
||||||
foreach($docs as $doc) {
|
foreach($docs as $doc) {
|
||||||
echo $doc->getName()."\n";
|
echo $doc->getName().PHP_EOL;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ class SeedDMS_Task_Indexer_Process_Folder { /* {{{ */
|
||||||
$documents = $folder->getDocuments();
|
$documents = $folder->getDocuments();
|
||||||
if($documents) {
|
if($documents) {
|
||||||
$lucenesearch = $this->fulltextservice->Search();
|
$lucenesearch = $this->fulltextservice->Search();
|
||||||
echo $folder->getFolderPathPlain()."\n";
|
echo $folder->getFolderPathPlain().PHP_EOL;
|
||||||
foreach($documents as $document) {
|
foreach($documents as $document) {
|
||||||
echo $document->getId().":".$document->getName()." ";
|
echo $document->getId().":".$document->getName()." ";
|
||||||
/* If the document wasn't indexed before then just add it */
|
/* If the document wasn't indexed before then just add it */
|
||||||
|
@ -181,5 +181,75 @@ class SeedDMS_IndexingDocumentsTask extends SeedDMS_SchedulerTaskBase { /* {{{ *
|
||||||
}
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for processing a single folder
|
||||||
|
*
|
||||||
|
* SeedDMS_Task_CheckSum_Process_Folder::process() is used as a callable when
|
||||||
|
* iterating over all folders recursively.
|
||||||
|
*/
|
||||||
|
class SeedDMS_Task_CheckSum_Process_Folder { /* {{{ */
|
||||||
|
public function __construct() { /* {{{ */
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function process($folder) { /* {{{ */
|
||||||
|
$dms = $folder->getDMS();
|
||||||
|
$documents = $folder->getDocuments();
|
||||||
|
if($documents) {
|
||||||
|
foreach($documents as $document) {
|
||||||
|
$versions = $document->getContent();
|
||||||
|
foreach($versions as $version) {
|
||||||
|
if(file_exists($dms->contentDir.$version->getPath())) {
|
||||||
|
$checksum = SeedDMS_Core_File::checksum($dms->contentDir.$version->getPath());
|
||||||
|
if($checksum != $version->getChecksum()) {
|
||||||
|
echo $document->getId().':'.$version->getVersion().' wrong checksum'.PHP_EOL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo $document->getId().':'.$version->getVersion().' missing content'.PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class containing methods for running a scheduled task
|
||||||
|
*
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @package SeedDMS
|
||||||
|
* @subpackage core
|
||||||
|
*/
|
||||||
|
class SeedDMS_CheckSumTask extends SeedDMS_SchedulerTaskBase { /* {{{ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the task
|
||||||
|
*
|
||||||
|
* @param $task task to be executed
|
||||||
|
* @param $dms dms
|
||||||
|
* @return boolean true if task was executed succesfully, otherwise false
|
||||||
|
*/
|
||||||
|
public function execute($task) {
|
||||||
|
$dms = $this->dms;
|
||||||
|
$taskparams = $task->getParameter();
|
||||||
|
$folder = $dms->getRootFolder();
|
||||||
|
|
||||||
|
$folderprocess = new SeedDMS_Task_CheckSum_Process_Folder();
|
||||||
|
$tree = new SeedDMS_FolderTree($folder, array($folderprocess, 'process'));
|
||||||
|
call_user_func(array($folderprocess, 'process'), $folder);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription() {
|
||||||
|
return 'Check all documents for a propper checksum';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAdditionalParams() {
|
||||||
|
return array(
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
$GLOBALS['SEEDDMS_SCHEDULER']['tasks']['core']['expireddocs'] = 'SeedDMS_ExpiredDocumentsTask';
|
$GLOBALS['SEEDDMS_SCHEDULER']['tasks']['core']['expireddocs'] = 'SeedDMS_ExpiredDocumentsTask';
|
||||||
$GLOBALS['SEEDDMS_SCHEDULER']['tasks']['core']['indexingdocs'] = 'SeedDMS_IndexingDocumentsTask';
|
$GLOBALS['SEEDDMS_SCHEDULER']['tasks']['core']['indexingdocs'] = 'SeedDMS_IndexingDocumentsTask';
|
||||||
|
$GLOBALS['SEEDDMS_SCHEDULER']['tasks']['core']['checksum'] = 'SeedDMS_CheckSumTask';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user