RUN apt -y --no-install-recommends install openssh-server rsyslog
RUN apt -y --no-install-recommends install wine libwine wine64
RUN apt -y --no-install-recommends install pdfposter rename
-RUN apt -y --no-install-recommends install jdupes
+RUN apt -y --no-install-recommends install jdupes symlinks
RUN apt -y --no-install-recommends install dnsutils
RUN apt -y --no-install-recommends install locales
// __('!!Paramètres des fluidbooks')
-use App\Fluidbook\Compiler\Compiler;
use App\Fluidbook\Link\LinksData;
use App\Models\FluidbookPublication;
use App\Models\User;
use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
use Cubist\Util\Files\Files;
use Illuminate\Http\UploadedFile;
-use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Route;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
-use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
-use Prologue\Alerts\Facades\Alert;
trait LinksOperation
--- /dev/null
+<?php
+
+namespace App\Jobs\Maintenance;
+
+use App\Jobs\Base;
+use App\Models\FluidbookPublication;
+use Cubist\Util\Text;
+
+class ListWorkingSymlinks extends Base
+{
+
+
+ public function handle()
+ {
+ foreach (FluidbookPublication::withoutGlobalScopes()->where('created_ok', 1)->get() as $fluidbook) {
+ static::parseFluidbookDir($fluidbook);
+ }
+ }
+
+ /**
+ * @param $fluidbook FluidbookPublication|int
+ * @return void
+ */
+
+ protected static function parseFluidbookDir($fluidbook)
+ {
+ if (!($fluidbook instanceof FluidbookPublication)) {
+ $fluidbook = FluidbookPublication::withoutGlobalScopes()->find($fluidbook);
+ }
+
+ /* @var $fluidbook FluidbookPublication */
+ $dir = $fluidbook->getAssetDir();
+ if (!file_exists($dir)) {
+ echo 'skip ' . $dir . " (not exists)\n";
+ return;
+ }
+ echo 'check ' . $dir . "\n";
+ $output = `symlinks -rv $dir`;
+ $changed = false;
+ $outlinks = Text::explodeNewLines($output);
+ if (!count($outlinks)) {
+ echo 'skip ' . $dir . " (no symlinks)\n";
+ return;
+ }
+ $links = static::getWorkingSymlinks();
+ foreach ($outlinks as $l) {
+ if (preg_match('/absolute: (.*) -> (.*)/', $l, $matches)) {
+ $link = $matches[1];
+ $target = $matches[2];
+ if (!isset($links[$target])) {
+ $links[$target] = [];
+ }
+ if (!isset($links[$target][$link])) {
+ $links[$target][$link] = true;
+ $changed = true;
+ }
+ }
+ }
+ if (!$changed) {
+ echo 'skip ' . $dir . " (nothing changed)\n";
+ return;
+ }
+ static::saveWorkingSymlinks($links);
+ }
+
+ protected static function _getCacheFile()
+ {
+ return protected_path('fluidbookpublication/cache/working_symlinks.json');
+ }
+
+ public static function getWorkingSymlinks()
+ {
+ if(!file_exists(static::_getCacheFile())) {
+ return [];
+ }
+ return json_decode(file_get_contents(static::_getCacheFile()), true) ?? [];
+ }
+
+ public static function saveWorkingSymlinks($links)
+ {
+ file_put_contents(static::_getCacheFile(), json_encode($links));
+ }
+}