Fixed: Clean folder when deleting single folder

This commit is contained in:
philipp lang 2021-10-31 21:12:16 +01:00
parent 58d4f260da
commit 6b0ab3182c
2 changed files with 16 additions and 0 deletions

View File

@ -51,6 +51,7 @@ class ResizeMake extends Command
if ($this->option('folder')) { if ($this->option('folder')) {
throw_unless(in_array($this->option('folder'), array_column(Setting::get('folders'), 'folder')), Exception::class, 'Folder not found'); throw_unless(in_array($this->option('folder'), array_column(Setting::get('folders'), 'folder')), Exception::class, 'Folder not found');
Storage::deleteDirectory('uploads/public/c'.$this->option('folder'));
$this->resize($this->option('folder')); $this->resize($this->option('folder'));
return; return;
} }

View File

@ -63,4 +63,19 @@ class ResizeMakeTest extends TestCase
$this->assertFileCount(1, 'pages'); $this->assertFileCount(1, 'pages');
} }
public function testCleanSingleFolderBeforeResizing()
{
Setting::set('folders', [
['folder' => '/pages'],
['folder' => 'otherdir'],
]);
Setting::set('sizes', []);
Setting::set('breakpoints', []);
Storage::put('uploads/public/c/pages/test-100x100.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get());
Artisan::call('resize:make', ['-f' => '/pages']);
$this->assertFileCount(0, 'pages');
}
} }