mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-43390 files: Only lock when locking is not prevented
This commit is contained in:
parent
d25049c0fc
commit
e946e06322
1 changed files with 9 additions and 1 deletions
|
@ -1721,6 +1721,8 @@ class file_storage {
|
||||||
* @return array (contenthash, filesize, newfile)
|
* @return array (contenthash, filesize, newfile)
|
||||||
*/
|
*/
|
||||||
public function add_string_to_pool($content) {
|
public function add_string_to_pool($content) {
|
||||||
|
global $CFG;
|
||||||
|
|
||||||
$contenthash = sha1($content);
|
$contenthash = sha1($content);
|
||||||
$filesize = strlen($content); // binary length
|
$filesize = strlen($content); // binary length
|
||||||
|
|
||||||
|
@ -1755,7 +1757,13 @@ class file_storage {
|
||||||
// Hopefully this works around most potential race conditions.
|
// Hopefully this works around most potential race conditions.
|
||||||
|
|
||||||
$prev = ignore_user_abort(true);
|
$prev = ignore_user_abort(true);
|
||||||
$newsize = file_put_contents($hashfile.'.tmp', $content, LOCK_EX);
|
|
||||||
|
if (!empty($CFG->preventfilelocking)) {
|
||||||
|
$newsize = file_put_contents($hashfile.'.tmp', $content);
|
||||||
|
} else {
|
||||||
|
$newsize = file_put_contents($hashfile.'.tmp', $content, LOCK_EX);
|
||||||
|
}
|
||||||
|
|
||||||
if ($newsize === false) {
|
if ($newsize === false) {
|
||||||
// Borked permissions most likely.
|
// Borked permissions most likely.
|
||||||
ignore_user_abort($prev);
|
ignore_user_abort($prev);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue