|
|
|
@ -277,7 +277,27 @@ public class VaaSyncService { |
|
|
|
(int) (endTime - begTime), channelPhone, phone, isOutgoing, isAnswered); |
|
|
|
|
|
|
|
// 下载录音文件(无重试)
|
|
|
|
if (!Files.exists(localFile) || Files.size(localFile) == 0) { |
|
|
|
// 文件不存在、大小为0、或小于1KB(可能损坏)时重新下载
|
|
|
|
boolean needDownload = !Files.exists(localFile) || Files.size(localFile) < 1024; |
|
|
|
// 额外校验:已存在文件也可能是HTML错误页面,检查文件头
|
|
|
|
if (!needDownload) { |
|
|
|
try { |
|
|
|
byte[] header = new byte[16]; |
|
|
|
try (java.io.RandomAccessFile raf = new java.io.RandomAccessFile(localFile.toFile(), "r")) { |
|
|
|
raf.readFully(header); |
|
|
|
} |
|
|
|
String headerStr = new String(header, "ASCII").trim().toLowerCase(); |
|
|
|
if (headerStr.startsWith("<!doctype") || headerStr.startsWith("<html")) { |
|
|
|
logger.warn("【录音】本地文件为HTML页面,重新下载: {}", fileName); |
|
|
|
needDownload = true; |
|
|
|
Files.delete(localFile); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.warn("【录音】校验本地文件失败,重新下载: {}", fileName); |
|
|
|
needDownload = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (needDownload) { |
|
|
|
String fileUrl = "http://" + deviceHost + filePath; |
|
|
|
vaaHttpUtil.httpDown(fileUrl, localPath, authToken); |
|
|
|
logger.info("【录音】下载完成: {} ({} 字节)", fileName, Files.size(localFile)); |
|
|
|
|