Commit 591240c1 by 李进峰

增加错误日志

parent 1b75903b
...@@ -85,33 +85,41 @@ public class DeployController { ...@@ -85,33 +85,41 @@ public class DeployController {
String targetBotAccount = requestBody.getString("targetBotAccount"); String targetBotAccount = requestBody.getString("targetBotAccount");
String tmpFileFullPathStr = Initialize.AUDIO_DIR+tmpFileRelativePathStr; String tmpFileFullPathStr = Initialize.AUDIO_DIR+tmpFileRelativePathStr;
Path tmpFileFullPath = Paths.get(tmpFileFullPathStr); Path tmpFileFullPath = Paths.get(tmpFileFullPathStr);
if(Files.exists(tmpFileFullPath) if(!Files.exists(tmpFileFullPath) && Files.isDirectory(tmpFileFullPath) ) {
&& !Files.isDirectory(tmpFileFullPath) ServerResponse<Object> result = ServerResponse.createByError();
&& StringUtils.endsWith(tmpFileRelativePathStr,".mp3") result.setMsg("缓存文件不存在!");
&& tmpFileRelativePathStr.startsWith("/game_editor_tmp")) { log.error(tmpFileFullPath.toString()+"路径不存在,或者是目录");
try { return result;
String tmpFileRelativePathStr2 = tmpFileRelativePathStr.substring("/game_editor_tmp".length());
if(tmpFileRelativePathStr2.startsWith(File.separator+targetBotAccount)) {
tmpFileRelativePathStr2 = tmpFileRelativePathStr2.substring((File.separator+targetBotAccount).length());
}
String targetFileRelativePathStr = File.separator+targetBotAccount+tmpFileRelativePathStr2;
String targetFileFullPathStr = Initialize.AUDIO_DIR+targetFileRelativePathStr;
Path targetFileFullPath = Paths.get(targetFileFullPathStr);
File fileDistFile = new File(targetFileFullPathStr);
if(!fileDistFile.getParentFile().exists()) {
fileDistFile.mkdirs();
}
Files.move(tmpFileFullPath, targetFileFullPath,
StandardCopyOption.REPLACE_EXISTING);
FileUtil.deleteFile(new File(tmpFileFullPathStr));
return ServerResponse.createBySuccess(targetFileRelativePathStr);
} catch (Exception e) {
e.printStackTrace();
}
} }
return ServerResponse.createByError(); if(!StringUtils.endsWith(tmpFileRelativePathStr,".mp3")
&& !tmpFileRelativePathStr.startsWith("/game_editor_tmp")) {
ServerResponse<Object> result = ServerResponse.createByError();
result.setMsg("地址前缀或者后缀有问题!");
log.error(tmpFileFullPath.toString()+"路径不存在,或者是目录");
return result;
}
try {
String tmpFileRelativePathStr2 = tmpFileRelativePathStr.substring("/game_editor_tmp".length());
if(tmpFileRelativePathStr2.startsWith(File.separator+targetBotAccount)) {
tmpFileRelativePathStr2 = tmpFileRelativePathStr2.substring((File.separator+targetBotAccount).length());
}
String targetFileRelativePathStr = File.separator+targetBotAccount+tmpFileRelativePathStr2;
String targetFileFullPathStr = Initialize.AUDIO_DIR+targetFileRelativePathStr;
Path targetFileFullPath = Paths.get(targetFileFullPathStr);
File fileDistFile = new File(targetFileFullPathStr);
if(!fileDistFile.getParentFile().exists()) {
fileDistFile.mkdirs();
}
Files.move(tmpFileFullPath, targetFileFullPath,
StandardCopyOption.REPLACE_EXISTING);
FileUtil.deleteFile(new File(tmpFileFullPathStr));
return ServerResponse.createBySuccess(targetFileRelativePathStr);
} catch (Exception e) {
e.printStackTrace();
log.error("请求体:"+requestBody);
return ServerResponse.createByError();
}
} }
@GetMapping("/background/audio") @GetMapping("/background/audio")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment