diff --git a/classes/local/store/digitalocean/client.php b/classes/local/store/digitalocean/client.php index 226636d6..f7946d34 100644 --- a/classes/local/store/digitalocean/client.php +++ b/classes/local/store/digitalocean/client.php @@ -40,7 +40,6 @@ class client extends s3_client { public function __construct($config) { global $CFG; $this->autoloader = $CFG->dirroot . '/local/aws/sdk/aws-autoloader.php'; - $this->testdelete = false; if ($this->get_availability() && !empty($config)) { require_once($this->autoloader); diff --git a/classes/local/store/object_client.php b/classes/local/store/object_client.php index 9121a824..e4a2b0d4 100644 --- a/classes/local/store/object_client.php +++ b/classes/local/store/object_client.php @@ -137,6 +137,11 @@ public function proxy_range_request(\stored_file $file, $ranges); */ public function test_range_request($filesystem); + /** + * If should test deletion as part of testing connection. + * @return bool + */ + public function should_test_delete(): bool; } diff --git a/classes/local/store/object_client_base.php b/classes/local/store/object_client_base.php index 4f03418d..1dfa02f3 100644 --- a/classes/local/store/object_client_base.php +++ b/classes/local/store/object_client_base.php @@ -38,10 +38,6 @@ abstract class object_client_base implements object_client { * @var mixed */ protected $expirationtime; - /** - * @var bool - */ - protected $testdelete = true; /** * @var int */ @@ -57,6 +53,15 @@ abstract class object_client_base implements object_client { /** @var object $config Client config. */ protected $config; + /** + * If deletion should be tested. + * Only tested when the deleteexternal setting is not set to 'no' + * @return bool + */ + public function should_test_delete(): bool { + return !empty($this->config) && $this->config->deleteexternal != TOOL_OBJECTFS_DELETE_EXTERNAL_NO; + } + /** * construct * @param \stdClass $config @@ -120,7 +125,7 @@ public function define_client_check() { if ($connection->success) { $output .= $OUTPUT->notification(get_string('settings:connectionsuccess', 'tool_objectfs'), 'notifysuccess'); // Check permissions if we can connect. - $permissions = $this->test_permissions($this->testdelete); + $permissions = $this->test_permissions($this->should_test_delete()); if ($permissions->success) { $output .= $OUTPUT->notification(key($permissions->messages), 'notifysuccess'); } else { diff --git a/classes/local/store/s3/client.php b/classes/local/store/s3/client.php index a6e2598e..23c495af 100644 --- a/classes/local/store/s3/client.php +++ b/classes/local/store/s3/client.php @@ -767,7 +767,7 @@ public function define_client_check_sdk($config) { if ($connection->success) { $output .= $OUTPUT->notification(get_string('settings:aws:sdkcredsok', 'tool_objectfs'), 'notifysuccess'); // Check permissions if we can connect. - $permissions = $this->test_permissions($this->testdelete); + $permissions = $this->test_permissions($this->should_test_delete()); if ($permissions->success) { $output .= $OUTPUT->notification(key($permissions->messages), 'notifysuccess'); } else {