| $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;
} ?>