mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-43390 files: Only lock when locking is not prevented
This commit is contained in:
parent
5fd0df97c5
commit
10ccdfb8cd
@ -1721,6 +1721,8 @@ class file_storage {
|
||||
* @return array (contenthash, filesize, newfile)
|
||||
*/
|
||||
public function add_string_to_pool($content) {
|
||||
global $CFG;
|
||||
|
||||
$contenthash = sha1($content);
|
||||
$filesize = strlen($content); // binary length
|
||||
|
||||
@ -1755,7 +1757,13 @@ class file_storage {
|
||||
// Hopefully this works around most potential race conditions.
|
||||
|
||||
$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) {
|
||||
// Borked permissions most likely.
|
||||
ignore_user_abort($prev);
|
||||
|
Loading…
x
Reference in New Issue
Block a user