Skip to content
Snippets Groups Projects

Made sure upload does not fail on filesystems that do not support locking.

1 file
+ 7
3
Compare changes
  • Side-by-side
  • Inline
@@ -177,7 +177,7 @@ class UploadController extends ControllerBase {
}
// Acquire an exclusive lock.
if (!flock($fp, LOCK_EX)) {
if (stream_supports_lock($fp) && !flock($fp, LOCK_EX)) {
fclose($fp);
throw new LockAcquiringException("Couldn't acquire an exclusive lock for ". FileWidgetFormAlter::getUploadUri($upload) . ".");
}
@@ -194,7 +194,9 @@ class UploadController extends ControllerBase {
}
catch (\Exception $e) {
$transaction->rollback();
flock($fp, LOCK_UN);
if (stream_supports_lock($fp)) {
flock($fp, LOCK_UN);
}
fclose($fp);
throw new FileWriteException('Failed to write chunk.');
}
@@ -204,7 +206,9 @@ class UploadController extends ControllerBase {
// Flush the output then unlock and close the file.
fflush($fp);
flock($fp, LOCK_UN);
if (stream_supports_lock($fp)) {
flock($fp, LOCK_UN);
}
fclose($fp);
// Return the updated number of uploaded chunks.
Loading