Fix "Implement a class for automatic temporary file handling"

TemporaryFile::commit throws instead of returning a bool.
This commit is contained in:
Alexei Sorokin 2020-09-14 20:37:48 +03:00
parent 001629b6dd
commit d2c7d70f49
2 changed files with 12 additions and 2 deletions

View File

@ -517,7 +517,12 @@ class MediaFile
if ($media === 'image') { if ($media === 'image') {
$result = rename($outpath, $filepath); $result = rename($outpath, $filepath);
} else { } else {
$result = $tempfile->commit($filepath); try {
$tempfile->commit($filepath);
$result = true;
} catch (TemporaryFileException $e) {
$result = false;
}
} }
if (!$result) { if (!$result) {
// TRANS: Server exception thrown when a file upload operation fails because the file could // TRANS: Server exception thrown when a file upload operation fails because the file could

View File

@ -115,7 +115,12 @@ class FFmpegPlugin extends Plugin
} }
if ($success) { if ($success) {
$success = $tempfile->commit($outpath); try {
$tempfile->commit($outpath);
} catch (TemporaryFileException $e) {
$this->log(LOG_ERR, 'Unable to save the GIF image');
$success = false;
}
} }
@unlink($palette); @unlink($palette);