refactor(ota): 优化文件路径计算逻辑

- 将 root_path() 函数调用替换为 ROOT_PATH 常量
- 提高代码可读性和性能
- 统一路径常量使用方式
This commit is contained in:
2026-04-10 09:07:55 +08:00
parent 125518aa98
commit 73f5e7fa14

View File

@@ -131,7 +131,7 @@ class Ota extends Api
*/ */
private function calculateFileInfo($relativePath) private function calculateFileInfo($relativePath)
{ {
$fullPath = root_path() . 'public' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . ltrim($relativePath, '/'); $fullPath = ROOT_PATH . 'public' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . ltrim($relativePath, '/');
if (!file_exists($fullPath)) { if (!file_exists($fullPath)) {
return null; return null;
} }