directory === $target || realpath($manifest->directory) === realpath($target)) { return $callback($target); } File::ensureDirectoryExists(dirname($target)); $staged = dirname($target).DIRECTORY_SEPARATOR.'.staging-'.Str::random(12); try { throw_unless(File::copyDirectory($manifest->directory, $staged), InvalidExtensionException::class, 'Unable to stage extension package.'); $this->validator->fromDirectory($staged); return $this->files->run([$target => $staged], fn () => $callback($target)); } finally { rescue(fn () => $this->files->delete($staged)); } } }