diff --git a/app/Actions/UpdateVaultNode.php b/app/Actions/UpdateVaultNode.php index 5aea94f..17e8be0 100644 --- a/app/Actions/UpdateVaultNode.php +++ b/app/Actions/UpdateVaultNode.php @@ -11,11 +11,11 @@ final readonly class UpdateVaultNode { /** * @param array{ - * parent_id: int|null, - * is_file: bool, - * name: string, - * extension: string|null, - * content: string|null + * parent_id?: int|null, + * is_file?: bool, + * name?: string, + * extension?: string|null, + * content?: string|null * } $attributes */ public function handle(VaultNode $node, array $attributes): void @@ -30,12 +30,16 @@ final readonly class UpdateVaultNode Storage::disk('local')->put($originalPath, $attributes['content'] ?? ''); } - if (!$node->wasChanged('name')) { - return; + // Rename node on disk + if ($node->wasChanged('name')) { + $path = new GetPathFromVaultNode()->handle($node); + Storage::disk('local')->move($originalPath, $path); } - // Rename node on disk - $path = new GetPathFromVaultNode()->handle($node); - Storage::disk('local')->move($originalPath, $path); + // Move node on disk + if ($node->wasChanged('parent_id')) { + $path = new GetPathFromVaultNode()->handle($node); + Storage::disk('local')->move($originalPath, $path); + } } }