1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-02 18:08:26 +01:00

Fix mishandling of chunk threshold in Diffusion for installs with no chunk engines available

Summary: Fixes T10273. The threshold is `null` if no chunk engines are available, but the code didn't handle this properly.

Test Plan: Disabled all chunk engines, reloaded, hit issue described in task. Applied patch, got clean file content.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10273

Differential Revision: https://secure.phabricator.com/D15179
This commit is contained in:
epriestley 2016-02-03 14:44:19 -08:00
parent 6bb24e1d0c
commit 68254a046f

View file

@ -92,21 +92,27 @@ abstract class PhabricatorFileUploadSource
$threshold = PhabricatorFileStorageEngine::getChunkThreshold(); $threshold = PhabricatorFileStorageEngine::getChunkThreshold();
// If we don't know how large the file is, we're going to read some data if ($threshold === null) {
// from it until we know whether it's a small file or not. This will give // If there are no chunk engines available, we clearly can't chunk the
// us enough information to make a decision about chunking. // file.
$length = $this->getDataLength(); $this->shouldChunk = false;
if ($length === null) { } else {
$rope = $this->getRope(); // If we don't know how large the file is, we're going to read some data
while ($this->readFileData()) { // from it until we know whether it's a small file or not. This will give
$length = $rope->getByteLength(); // us enough information to make a decision about chunking.
if ($length > $threshold) { $length = $this->getDataLength();
break; if ($length === null) {
$rope = $this->getRope();
while ($this->readFileData()) {
$length = $rope->getByteLength();
if ($length > $threshold) {
break;
}
} }
} }
}
$this->shouldChunk = ($length > $threshold); $this->shouldChunk = ($length > $threshold);
}
return $this->shouldChunk; return $this->shouldChunk;
} }