diff --git a/classes/local/manager.php b/classes/local/manager.php index c746b9c2..46fd243e 100644 --- a/classes/local/manager.php +++ b/classes/local/manager.php @@ -27,6 +27,9 @@ use stdClass; use tool_objectfs\local\store\object_file_system; +use tool_objectfs\local\object_manipulator\manipulator_builder; +use tool_objectfs\local\object_manipulator\pusher; +use tool_objectfs\local\object_manipulator\deleter; defined('MOODLE_INTERNAL') || die(); @@ -168,6 +171,12 @@ public static function update_object_by_hash($contenthash, $newlocation, $filesi } $DB->insert_record('tool_objectfs_objects', $newobject); + $manipulator_builder = new manipulator_builder(); + $extraconfig = new stdClass(); + $extraconfig->sqlfilterstring = "contenthash = '{$contenthash}'"; + $manipulator_builder->execute(pusher::class, $extraconfig); + $manipulator_builder->execute(deleter::class, $extraconfig); + return $newobject; } diff --git a/classes/local/object_manipulator/candidates/deleter_candidates.php b/classes/local/object_manipulator/candidates/deleter_candidates.php index e17a179e..cedb8798 100644 --- a/classes/local/object_manipulator/candidates/deleter_candidates.php +++ b/classes/local/object_manipulator/candidates/deleter_candidates.php @@ -39,7 +39,8 @@ public function get_candidates_sql() { FROM {tool_objectfs_objects} WHERE timeduplicated <= :consistancythreshold AND location = :location - AND filesize > :sizethreshold'; + AND filesize > :sizethreshold' . ( + empty($this->config->extraconfig->sqlfilterstring) ? "" : " AND " . $this->config->extraconfig->sqlfilterstring); } /** diff --git a/classes/local/object_manipulator/candidates/pusher_candidates.php b/classes/local/object_manipulator/candidates/pusher_candidates.php index a685a975..fe07b095 100644 --- a/classes/local/object_manipulator/candidates/pusher_candidates.php +++ b/classes/local/object_manipulator/candidates/pusher_candidates.php @@ -42,7 +42,8 @@ public function get_candidates_sql() { WHERE filesize > :threshold AND filesize < :maximum_file_size AND timeduplicated <= :maxcreatedtimestamp - AND location = :object_location'; + AND location = :object_location' . ( + empty($this->config->extraconfig->sqlfilterstring) ? "" : " AND " . $this->config->extraconfig->sqlfilterstring); } /** diff --git a/classes/local/object_manipulator/manipulator.php b/classes/local/object_manipulator/manipulator.php index a0cadaf8..df11f04d 100644 --- a/classes/local/object_manipulator/manipulator.php +++ b/classes/local/object_manipulator/manipulator.php @@ -115,7 +115,7 @@ public function execute(array $objectrecords) { } $this->logger->end_timing(); - $this->logger->output_move_statistics(); + // $this->logger->output_move_statistics(); } /** diff --git a/classes/local/object_manipulator/manipulator_builder.php b/classes/local/object_manipulator/manipulator_builder.php index 66e5ba41..7bb5cf30 100644 --- a/classes/local/object_manipulator/manipulator_builder.php +++ b/classes/local/object_manipulator/manipulator_builder.php @@ -68,8 +68,8 @@ class manipulator_builder { * @throws coding_exception * @throws moodle_exception */ - public function execute($manipulator) { - $this->build($manipulator); + public function execute($manipulator, $extraconfig = null) { + $this->build($manipulator, $extraconfig); if (empty($this->candidates)) { return; } @@ -86,10 +86,10 @@ public function execute($manipulator) { * @throws coding_exception * @throws moodle_exception */ - public function execute_all() { + public function execute_all($extraconfig = null) { foreach ($this->manipulators as $manipulator) { mtrace("Executing objectfs $manipulator"); - $this->execute($manipulator); + $this->execute($manipulator, $extraconfig); mtrace("Objectfs $manipulator successfully executed"); } } @@ -98,8 +98,9 @@ public function execute_all() { * @param string $manipulator * @throws moodle_exception */ - private function build($manipulator) { + private function build($manipulator, $extraconfig = null) { $this->config = manager::get_objectfs_config(); + $this->config->extraconfig = $extraconfig; $this->manipulatorclass = $manipulator; $this->logger = new aggregate_logger(); $this->finder = new candidates_finder($manipulator, $this->config); diff --git a/classes/local/store/object_file_system.php b/classes/local/store/object_file_system.php index 10692f1a..195a828f 100644 --- a/classes/local/store/object_file_system.php +++ b/classes/local/store/object_file_system.php @@ -267,11 +267,11 @@ public function copy_object_from_local_to_external_by_hash($contenthash, $object } } - $this->logger->log_object_move('copy_object_from_local_to_external', - $initiallocation, - $finallocation, - $contenthash, - $objectsize); + // $this->logger->log_object_move('copy_object_from_local_to_external', + // $initiallocation, + // $finallocation, + // $contenthash, + // $objectsize); return $finallocation; } @@ -296,11 +296,11 @@ public function delete_object_from_local_by_hash($contenthash, $objectsize = 0) } } - $this->logger->log_object_move('delete_local_object', - $initiallocation, - $finallocation, - $contenthash, - $objectsize); + // $this->logger->log_object_move('delete_local_object', + // $initiallocation, + // $finallocation, + // $contenthash, + // $objectsize); return $finallocation; } diff --git a/classes/local/store/s3/client.php b/classes/local/store/s3/client.php index 31288859..a464dd0f 100644 --- a/classes/local/store/s3/client.php +++ b/classes/local/store/s3/client.php @@ -47,6 +47,7 @@ class client extends object_client_base { protected $client; protected $bucket; private $signingmethod; + private $bucketkeyprefix; public function __construct($config) { global $CFG;