diff --git a/app/Actions/Diagnostics/Pipes/Checks/BasicPermissionCheck.php b/app/Actions/Diagnostics/Pipes/Checks/BasicPermissionCheck.php index 71a54972428..e526a701773 100644 --- a/app/Actions/Diagnostics/Pipes/Checks/BasicPermissionCheck.php +++ b/app/Actions/Diagnostics/Pipes/Checks/BasicPermissionCheck.php @@ -7,6 +7,8 @@ use App\Exceptions\Handler; use App\Exceptions\Internal\InvalidConfigOption; use App\Facades\Helpers; +use App\Image\Files\ProcessableJobFile; +use App\Livewire\Components\Forms\Add\Upload; use App\Models\SymLink; use Illuminate\Contracts\Container\BindingResolutionException; use Illuminate\Support\Facades\Storage; @@ -106,6 +108,8 @@ function (int $gid): string { $disks = [ AbstractSizeVariantNamingStrategy::getImageDisk(), Storage::disk(SymLink::DISK_NAME), + Storage::disk(ProcessableJobFile::DISK_NAME), + Storage::disk(Upload::DISK_NAME), ]; foreach ($disks as $disk) { @@ -300,7 +304,7 @@ private function anonymize(string $path): string $this->realPaths[] = public_path(); $this->anonymizePaths[] = Helpers::censor(public_path(), 0.2); $this->realPaths[] = storage_path(); - $this->anonymizePaths[] = Helpers::censor(storage_path(), 0.2); + $this->anonymizePaths[] = Helpers::censor(storage_path(), 0.4); $this->realPaths[] = config('filesystems.disks.images.root'); $this->anonymizePaths[] = Helpers::censor(config('filesystems.disks.images.root'), 0.2); } diff --git a/app/Image/Files/ProcessableJobFile.php b/app/Image/Files/ProcessableJobFile.php index b083400bdea..ef58a212ab0 100644 --- a/app/Image/Files/ProcessableJobFile.php +++ b/app/Image/Files/ProcessableJobFile.php @@ -3,6 +3,7 @@ namespace App\Image\Files; use App\Exceptions\MediaFileOperationException; +use Illuminate\Support\Facades\Storage; use function Safe\mkdir; /** @@ -14,6 +15,7 @@ class ProcessableJobFile extends NativeLocalFile { use LoadTemporaryFileTrait; + public const DISK_NAME = 'image-jobs'; protected string $fakeBaseName; @@ -39,7 +41,7 @@ public function __construct(string $fileExtension, string $fakeBaseName = '') */ protected function getFileBasePath(): string { - $tempDirPath = storage_path() . DIRECTORY_SEPARATOR . 'image-jobs'; + $tempDirPath = Storage::disk(self::DISK_NAME)->path(''); if (!file_exists($tempDirPath)) { mkdir($tempDirPath); diff --git a/app/Livewire/Components/Forms/Add/Upload.php b/app/Livewire/Components/Forms/Add/Upload.php index bcf74b96dd6..e94e9992c3c 100644 --- a/app/Livewire/Components/Forms/Add/Upload.php +++ b/app/Livewire/Components/Forms/Add/Upload.php @@ -32,6 +32,7 @@ class Upload extends Component { use WithFileUploads; use InteractWithModal; + public const DISK_NAME = 'livewire-upload'; /** * @var string|null albumId of where to upload the picture @@ -99,7 +100,7 @@ public function updatedUploads($value, string $key): void $fileDetails = $this->uploads[$index]; /** @var TemporaryUploadedFile $chunkFile */ $chunkFile = $fileDetails['fileChunk']; - $final = new NativeLocalFile(Storage::path('/livewire-tmp/' . $fileDetails['uuidName'])); + $final = new NativeLocalFile(Storage::disk(self::DISK_NAME)->path($fileDetails['uuidName'])); $final->append($chunkFile->readStream()); $chunkFile->delete(); @@ -118,7 +119,7 @@ public function triggerProcessing(): void { foreach ($this->uploads as $idx => $fileData) { if ($fileData['stage'] === FileStatus::READY->value) { - $uploadedFile = new NativeLocalFile(Storage::path('/livewire-tmp/' . $fileData['uuidName'])); + $uploadedFile = new NativeLocalFile(Storage::disk(self::DISK_NAME)->path($fileData['uuidName'])); $processableFile = new ProcessableJobFile( $fileData['extension'], $fileData['fileName'] diff --git a/config/filesystems.php b/config/filesystems.php index d2a75687ce7..f33abe1f787 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -132,6 +132,29 @@ function renv_cond(string $cst): string 'visibility' => 'public', ], + // We use this space to temporarily store images when uploading. + // Mostly chunks and incomplete images are placed here + 'livewire-upload' => [ + 'driver' => 'local', + 'root' => env('LYCHEE_TMP_UPLOAD', storage_path('livewire-tmp')), + 'visibility' => 'private', + ], + + // We use this space to process the images, + 'image-jobs' => [ + 'driver' => 'local', + 'root' => env('LYCHEE_IMAGE_JOBS', storage_path('image-jobs')), + 'visibility' => 'private', + ], + + // This is where we extract zip files before importing them. + 'extract-jobs' => [ + 'driver' => 'local', + 'root' => env('LYCHEE_EXTRACT_JOBS', storage_path('extract-jobs')), + 'visibility' => 'private', + ], + + // For tests purposes 'tmp-for-tests' => [ 'driver' => 'local', 'root' => storage_path('image-tmp/'),