Jelajahi Sumber

data dir fix

ljoaquim 1 Minggu lalu
induk
melakukan
a41c089525
1 mengubah file dengan 18 tambahan dan 1 penghapusan
  1. 18 1
      services/DocumentStorageService.php

+ 18 - 1
services/DocumentStorageService.php

@@ -8,7 +8,24 @@ class DocumentStorageService
 
     public function __construct(?string $rootDir = null)
     {
-        $this->rootDir = $rootDir ?? ($_ENV['DOCUMENTS_ROOT'] ?? '/data/documents');
+        if (is_string($rootDir) && trim($rootDir) !== '') {
+            $this->rootDir = $rootDir;
+            return;
+        }
+
+        $documentsRoot = (string)($_ENV['DOCUMENTS_ROOT'] ?? '');
+        if (trim($documentsRoot) !== '') {
+            $this->rootDir = $documentsRoot;
+            return;
+        }
+
+        $appRootDir = (string)($_ENV['ROOT_DIR'] ?? '');
+        if (trim($appRootDir) !== '') {
+            $this->rootDir = rtrim($appRootDir, '/') . '/data/documents';
+            return;
+        }
+
+        $this->rootDir = dirname(__DIR__) . '/data/documents';
     }
 
     public function sanitizeDocumentType(string $documentType): string