Skip to content

Commit

Permalink
bugfix: test delete according to objectfs config
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhilton committed Oct 15, 2024
1 parent dd8bc90 commit 1266114
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion classes/local/store/digitalocean/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions classes/local/store/object_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


15 changes: 10 additions & 5 deletions classes/local/store/object_client_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ abstract class object_client_base implements object_client {
* @var mixed
*/
protected $expirationtime;
/**
* @var bool
*/
protected $testdelete = true;
/**
* @var int
*/
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion classes/local/store/s3/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1266114

Please sign in to comment.