/**
* Returns the size of the file
*
* !! WARNING !!
* Calling this loads the entire file into memory,
* unless it is on a stream-capable filesystem.
* In case of bigger files this could throw exceptions,
* and will have heavy performance footprint.
* !! ------- !!
*
*/
public function getSize()
{
// This can only work on streamable files, so basically local files,
// still only perform it once even on local files to avoid bothering the filesystem.php g
if ($this->filesystem->getAdapter() instanceof StreamFactory && !$this->size) {
if ($this->streamWrapperPrefix) {
try {
$this->setSize(filesize($this->streamWrapperPrefix . $this->getKey()));
} catch (\Exception $e) {
// Fail gracefully if there was a problem with opening the file and
// let gaufrette load the file into memory allowing it to throw exceptions
// if that doesn't work either.
// Not empty to make the scrutiziner happy.
return parent::getSize();
}
}
}
return parent::getSize();
}