From 03b8c6035e71ad1d06aa258f135d1607e8ff1690 Mon Sep 17 00:00:00 2001 From: Krystian Duma Date: Sun, 17 Dec 2023 06:42:39 +0100 Subject: [PATCH] Smaller restriction files --- .../FileRestrictionsMapFileGeneratorExtension.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Extensions/FileRestrictionsMapFileGeneratorExtension.php b/app/Extensions/FileRestrictionsMapFileGeneratorExtension.php index 489b4e0..66d8292 100644 --- a/app/Extensions/FileRestrictionsMapFileGeneratorExtension.php +++ b/app/Extensions/FileRestrictionsMapFileGeneratorExtension.php @@ -64,8 +64,13 @@ public function hook(BuildStateInterface $buildState): void ->groupBy('url') ->map(function (Collection $packages) { return $packages->pluck('tags')->flatten(); - }); + }) + ->filter(fn (Collection $tags, string $url) => !str($url)->startsWith(['http://', 'https://'])); - Storage::disk('temp')->put(str('file_restrictions.json')->start('/')->start($buildState->getTempPrefix()), json_encode($packages->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + Storage::disk('temp')->deleteDirectory('file_restrictions'); + $packages->each(function (Collection $tags, string $url) use ($buildState) { + $path = str('_file_restrictions')->append('/')->append($url)->append('.json')->start('/')->start($buildState->getTempPrefix()); + Storage::disk('temp')->put($path, $tags->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + }); } }