commit 2dd41f4fd9c34c8b14de7b85f652a77d3f490b1b
parent 136c72b91ba941d1294e8cf818eaa0a9f3100a92
Author: Felicitus <felicitus@felicitus.org>
Date: Mon, 2 Nov 2015 16:51:26 +0100
Display disk usage in system information, fixed calculation of free disk space when using quotas
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/PartKeepr/UploadedFileBundle/Services/UploadedFileService.php b/src/PartKeepr/UploadedFileBundle/Services/UploadedFileService.php
@@ -5,6 +5,7 @@ namespace PartKeepr\UploadedFileBundle\Services;
use Gaufrette\Filesystem;
use PartKeepr\UploadedFileBundle\Entity\UploadedFile;
+use PartKeepr\UploadedFileBundle\Exceptions\DiskSpaceExhaustedException;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\File\File;
@@ -46,6 +47,11 @@ class UploadedFileService extends ContainerAware
$file->setSize($filesystemFile->getSize());
$storage = $this->getStorage($file);
+
+ if ($filesystemFile->getSize() > $this->container->get("partkeepr_systemservice")->getFreeDiskSpace()) {
+ throw new DiskSpaceExhaustedException();
+ }
+
$storage->write($file->getFullFilename(), file_get_contents($filesystemFile->getPathname()));
}