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');