diff --git a/README.md b/README.md index 202c5c4..481d0f6 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ sphinxsearch * Deploy the database using [MySQL Workbench](https://www.mysql.com/products/workbench) project presented in the `/database` folder * Install [Sphinx Search Server](https://sphinxsearch.com) * Configuration examples are placed at `/config` folder -* Make sure `/storage`, `/public/storage` folders writable +* Make sure `/storage`, `/public/snap` folders writable * Set up the `/crontab` scripts by following [example](https://github.com/YGGverse/YGGo/blob/main/config/crontab.txt) #### JSON API diff --git a/crontab/crawler.php b/crontab/crawler.php index 9336fc4..929b109 100644 --- a/crontab/crawler.php +++ b/crontab/crawler.php @@ -402,18 +402,23 @@ try { $time = time(); - @mkdir('../public/storage/snap/hp/' . $queueHostPage->hostPageId, 755, true); + $dir = chunk_split($queueHostPage->hostPageId, 1, '/'); + + @mkdir('../public/snap/hp/' . $dir, 755, true); $zip = new ZipArchive(); - if (true === $zip->open('../public/storage/snap/hp/' . $queueHostPage->hostPageId . '/' . $time . '.zip', ZipArchive::CREATE)) { + // Create new container + if (true === $zip->open('../public/snap/hp/' . $dir . $time . '.zip', ZipArchive::CREATE)) { + // Insert compressed snap data if (true === $zip->addFromString($queueHostPage->hostPageId . '.' . $time . '.' . preg_replace('|^[A-z-]+/([A-z-]+).*|ui', '$1', Filter::mime($contentType)), $content)) { + // Update DB registry $hostPagesSnapUrlAdded += $db->addHostPageSnapURL($queueHostPage->hostPageId, $crc32data, // do not create duplicated content snaps $crc32host, // multi host storage with same timestamp / crc32data - '/storage/snap/hp/' . $queueHostPage->hostPageId . '/' . $time . '.zip', // public url + '/snap/hp/' . $dir . $time . '.zip', // public url $time); $zip->close(); diff --git a/public/snap/index.html b/public/snap/index.html new file mode 100644 index 0000000..e69de29