Skip to content
Snippets Groups Projects
Commit 345788a9 authored by Jared Hancock's avatar Jared Hancock
Browse files

file: Don't crash when sending data to file backends

parent 9d7b99db
No related branches found
No related tags found
No related merge requests found
......@@ -363,13 +363,18 @@ class AttachmentFile {
// otherwise.
$succeeded = false;
foreach ($bks as $bk) {
if (isset($file['tmp_name'])) {
if ($bk->upload($file['tmp_name'])) {
try {
if (isset($file['tmp_name'])) {
if ($bk->upload($file['tmp_name'])) {
$succeeded = true; break;
}
}
elseif ($bk->write($file['data']) && $bk->flush()) {
$succeeded = true; break;
}
}
elseif ($bk->write($file['data']) && $bk->flush()) {
$succeeded = true; break;
catch (Exception $e) {
// Try next backend
}
// Fallthrough to default backend if different?
}
......@@ -418,11 +423,17 @@ class AttachmentFile {
// TODO: Make this resumable so that if the file cannot be migrated
// in the max_execution_time, the migration can be continued
// the next time the cron runs
while ($block = $source->read($target->getBlockSize())) {
hash_update($before, $block);
$target->write($block);
try {
while ($block = $source->read($target->getBlockSize())) {
hash_update($before, $block);
$target->write($block);
}
$target->flush();
}
catch (Exception $e) {
// Migration failed
return false;
}
$target->flush();
// Ask the backend to generate its own hash if at all possible
if (!($target_hash = $target->getHashDigest($common_algo))) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment