$rowNo $rowTitle $lineNumber $documentDate $constructor $pageCount $pageIndex "; */ $search[0] = str_replace("storage/documents/", "", $search[0]); $fullFolder = str_replace("storage/documents/", "", $fullFolder); $fullPath = $fullFolder . basename($fileName); Log::debug("πŸ› οΈ File path processing:"); Log::debug("πŸ“„ Original source path: storage/documents/" . $search[0]); Log::debug("πŸ“ Original folder path: storage/documents/" . $fullFolder); Log::debug("πŸ“„ Target filename: " . basename($fileName)); Log::debug("πŸ“„ Final target path: " . $fullPath); /* Log::info("fullPath: " . $fullPath); Log::info("search: " . $search[0]); Log::info("fullFolder: " . $fullFolder); */ try { if(Storage::exists($fullPath)) { $currentContent = md5(Storage::get($fullPath)); $newContent = md5(Storage::get($search[0])); Log::debug("πŸ“ Checking file: " . $fullPath); Log::debug("πŸ”‘ Current content MD5: " . $currentContent); Log::debug("πŸ”‘ New content MD5: " . $newContent); if ($currentContent !== $newContent) { $log = "πŸ”ƒβœ…".$search[0] . " old file deleted and new file copied" . "\n"; Log::debug("πŸ“ " . $log); Storage::delete($fullPath); Storage::copy($search[0], $fullPath); } else { $log = "🟰" . $search[0] . " already same file, not copied" . "\n"; Log::debug("πŸ“ " . $log); } } else { $log = "βœ…".$search[0] . " file copied" . "\n"; Log::debug("πŸ“ " . $log); Storage::copy($search[0], $fullPath); } echo($log); } catch (\Throwable $th) { $log = "❌" . $search[0] . " error ---> \n " . $th->getMessage() . "\n"; echo($log); Log::debug("❌ Error copying file: " . $search[0]); Log::debug("❌ Error message: " . $th->getMessage()); Log::debug("❌ Error trace: " . $th->getTraceAsString()); } Storage::append($fullFolder . 'log.txt', $log); Log::debug("πŸ“œ Appended to log file: " . $fullFolder . 'log.txt'); Log::debug("πŸ“œ Log entry: " . $log); $return = null; //= $tableRow; } else { $log = "❓$rowTitle - $lineNumber not found " . "\n"; echo($log); Log::debug("❓ Document not found: " . $rowTitle . " - " . $lineNumber); Log::debug("❓ Search path likely was: storage/documents/{$selectDocument['path']}/*{$lineNumber}*.pdf"); $fullFolder = str_replace("storage/documents/", "", $fullFolder); Storage::append($fullFolder . 'log.txt', $log); Log::debug("πŸ“œ Appended to log file: " . $fullFolder . 'log.txt'); $return = null; } return $return; } ?>