This commit is contained in:
@@ -28,11 +28,8 @@ func GetDocumentationDir() (string, error) {
|
||||
checkedDirs = append(checkedDirs, docDir)
|
||||
|
||||
if info, err := os.Stat(docDir); err == nil && info.IsDir() {
|
||||
absPath, err := filepath.Abs(docDir)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("获取绝对路径失败: %w", err)
|
||||
}
|
||||
return absPath, nil
|
||||
// 直接返回相对路径,不转换为绝对路径
|
||||
return docDir, nil
|
||||
}
|
||||
|
||||
// 尝试父目录
|
||||
@@ -177,22 +174,13 @@ func (f *PDFFinder) FindPDFByProductCode(productCode string) (string, error) {
|
||||
return "", fmt.Errorf("未找到产品代码为 %s 的PDF文档", productCode)
|
||||
}
|
||||
|
||||
// 转换为绝对路径
|
||||
absPath, err := filepath.Abs(foundPath)
|
||||
if err != nil {
|
||||
f.logger.Error("获取文件绝对路径失败",
|
||||
zap.String("file_path", foundPath),
|
||||
zap.Error(err),
|
||||
)
|
||||
return "", fmt.Errorf("获取文件绝对路径失败: %w", err)
|
||||
}
|
||||
|
||||
// 直接返回相对路径,不转换为绝对路径
|
||||
f.logger.Info("成功找到PDF文件",
|
||||
zap.String("product_code", productCode),
|
||||
zap.String("file_path", absPath),
|
||||
zap.String("file_path", foundPath),
|
||||
)
|
||||
|
||||
return absPath, nil
|
||||
return foundPath, nil
|
||||
}
|
||||
|
||||
// FindPDFByProductCodeWithFallback 根据产品代码查找PDF文件,支持多个可能的命名格式
|
||||
@@ -233,10 +221,6 @@ func (f *PDFFinder) FindPDFByProductCodeWithFallback(productCode string) (string
|
||||
return "", fmt.Errorf("未找到产品代码为 %s 的PDF文档", productCode)
|
||||
}
|
||||
|
||||
absPath, err := filepath.Abs(foundPath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("获取文件绝对路径失败: %w", err)
|
||||
}
|
||||
|
||||
return absPath, nil
|
||||
// 直接返回相对路径,不转换为绝对路径
|
||||
return foundPath, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user