Fixed: Move event has only target directory as second argument
continuous-integration/drone/push Build encountered an error Details

This commit is contained in:
philipp lang 2022-02-16 03:03:55 +01:00
parent 30bd3dc25f
commit 54fd872452
2 changed files with 3 additions and 3 deletions

View File

@ -78,11 +78,11 @@ class Plugin extends PluginBase
Event::listen('media.file.move', function($widget, $old, $new) { Event::listen('media.file.move', function($widget, $old, $new) {
if ((new StorageMediaPath($new))->shouldProcess() || (new StorageMediaPath($old))->shouldProcess()) { if ((new StorageMediaPath($new))->shouldProcess() || (new StorageMediaPath($old))->shouldProcess()) {
Queue::push(MoveJob::class, [$old, $new], Setting::get('queue')); Queue::push(MoveJob::class, [$old, $new.'/'.pathinfo($old, PATHINFO_FILENAME)], Setting::get('queue'));
} }
}); });
Event::listen('media.file.rename', function($widget, $old, $new) { Event::listen('media.file.rename', function($widget, $old, $new) {
if ((new StorageMediaPath($old))->shouldProcess()) { if ((new StorageMediaPath($new))->shouldProcess() || (new StorageMediaPath($old))->shouldProcess()) {
Queue::push(MoveJob::class, [$old, $new], Setting::get('queue')); Queue::push(MoveJob::class, [$old, $new], Setting::get('queue'));
} }
}); });

View File

@ -27,7 +27,7 @@ class MoveTest extends TestCase
$this->media->put('/pages/alt/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); $this->media->put('/pages/alt/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get());
UploadedFile::fake()->image('test.jpg', 100, 100)->storeAs('uploads/public/c/pages/alt', 'test-200x300.jpg', 'local'); UploadedFile::fake()->image('test.jpg', 100, 100)->storeAs('uploads/public/c/pages/alt', 'test-200x300.jpg', 'local');
Event::fire('media.file.move', [null, '/pages/alt/test.jpg', '/pages/neu/test.jpg']); Event::fire('media.file.move', [null, '/pages/alt/test.jpg', '/pages/neu']);
$this->assertFileCount(0, 'pages/alt'); $this->assertFileCount(0, 'pages/alt');
$this->assertHasFile('pages/neu/test-200x300.jpg'); $this->assertHasFile('pages/neu/test-200x300.jpg');