Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions classes/local/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/local/object_manipulator/manipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function execute(array $objectrecords) {
}

$this->logger->end_timing();
$this->logger->output_move_statistics();
// $this->logger->output_move_statistics();
}

/**
Expand Down
11 changes: 6 additions & 5 deletions classes/local/object_manipulator/manipulator_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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");
}
}
Expand All @@ -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);
Expand Down
20 changes: 10 additions & 10 deletions classes/local/store/object_file_system.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions classes/local/store/s3/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class client extends object_client_base {
protected $client;
protected $bucket;
private $signingmethod;
private $bucketkeyprefix;

public function __construct($config) {
global $CFG;
Expand Down