Skip to content

Commit

Permalink
fix: ensure proper lock release and error handling in objectfs manipu…
Browse files Browse the repository at this point in the history
…lator
  • Loading branch information
Vithusha Kethiri committed Jan 23, 2025
1 parent 0c2b62d commit 06ac446
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion classes/local/store/object_file_system.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,13 @@ protected function get_mimetype_from_hash(string $contenthash): string {

// We limit 1 because multiple files can have the same contenthash.
// However, they all have the same mimetype so it does not matter which one we query.
return $DB->get_field_sql('SELECT mimetype
$mimetype = $DB->get_field_sql('SELECT mimetype
FROM {files}
WHERE contenthash = :hash
LIMIT 1',
['hash' => $contenthash]);

return $mimetype ?? '';
}

/**
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 @@ -513,7 +513,7 @@ public function upload_to_s3($localpath, $contenthash, string $mimetype) {
$this->client, $this->bucket,
$this->bucketkeyprefix . $externalpath,
$filehandle,
'private',
'bucket-owner-full-control',
[
'params' => [
'ContentType' => $mimetype,
Expand Down

0 comments on commit 06ac446

Please sign in to comment.