diff --git a/Modules/Media/Tests/MaxFolderSizeRuleTest.php b/Modules/Media/Tests/MaxFolderSizeRuleTest.php index d81317439..feb487692 100644 --- a/Modules/Media/Tests/MaxFolderSizeRuleTest.php +++ b/Modules/Media/Tests/MaxFolderSizeRuleTest.php @@ -27,7 +27,7 @@ public function test_it_creates_instance_of_folder_size_validator() /** @test */ public function it_validates_max_folder_size_is_valid() { - $this->app['config']->set('asgard.media.config.max-total-size', 10000); // Mocked folder size: 480; Mocked image: ~8192 + $this->app['config']->set('asgard.media.config.max-total-size', 1000); // Mocked folder size: 510 $validator = $this->buildValidator(UploadedFile::fake()->image('avatar.jpg')); $this->assertTrue($validator->passes()); @@ -36,7 +36,7 @@ public function it_validates_max_folder_size_is_valid() /** @test */ public function it_validates_max_folder_size_is_invalid() { - $this->app['config']->set('asgard.media.config.max-total-size', 100); + $this->app['config']->set('asgard.media.config.max-total-size', 50); // Mocked folder size: 510 $validator = $this->buildValidator(UploadedFile::fake()->image('avatar.jpg')); $this->assertFalse($validator->passes()); diff --git a/Modules/Media/Validators/MaxFolderSizeRule.php b/Modules/Media/Validators/MaxFolderSizeRule.php index d3fa71d77..4428c6664 100644 --- a/Modules/Media/Validators/MaxFolderSizeRule.php +++ b/Modules/Media/Validators/MaxFolderSizeRule.php @@ -5,6 +5,7 @@ use Illuminate\Contracts\Validation\Rule; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; +use FilesystemIterator; use Symfony\Component\HttpFoundation\File\UploadedFile; class MaxFolderSizeRule implements Rule @@ -45,7 +46,7 @@ public function message() public function getDirSize($directory) : int { $size = 0; - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) { + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory,FilesystemIterator::SKIP_DOTS)) as $file) { $size += $file->getSize(); }