From 54fd8724526de36eaa8f5d9017773a36309975ad Mon Sep 17 00:00:00 2001 From: philipp lang Date: Wed, 16 Feb 2022 03:03:55 +0100 Subject: [PATCH] Fixed: Move event has only target directory as second argument --- Plugin.php | 4 ++-- tests/MoveTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugin.php b/Plugin.php index c0adcae..f447435 100644 --- a/Plugin.php +++ b/Plugin.php @@ -78,11 +78,11 @@ class Plugin extends PluginBase Event::listen('media.file.move', function($widget, $old, $new) { 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) { - if ((new StorageMediaPath($old))->shouldProcess()) { + if ((new StorageMediaPath($new))->shouldProcess() || (new StorageMediaPath($old))->shouldProcess()) { Queue::push(MoveJob::class, [$old, $new], Setting::get('queue')); } }); diff --git a/tests/MoveTest.php b/tests/MoveTest.php index a5f4a46..37bd7c6 100644 --- a/tests/MoveTest.php +++ b/tests/MoveTest.php @@ -27,7 +27,7 @@ class MoveTest extends TestCase $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'); - 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->assertHasFile('pages/neu/test-200x300.jpg');