修改保存逻辑:先发送文件到本地C++服务,成功后再保存到服务器
- 调整文件保存流程:首先向本地C++服务发送文件内容 - 只有在收到C++服务返回200状态码后才继续执行保存到服务器操作 - 如果C++服务响应失败,则跳过服务器保存,并提供相应提示 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
34
dist/extension.js
vendored
34
dist/extension.js
vendored
@@ -134,28 +134,30 @@ function activate(context) {
|
||||
if (doc.uri.scheme === 'squirrel') {
|
||||
const filePath = doc.uri.path.substring(1); // 去掉开头的 '/'
|
||||
const fileContent = doc.getText();
|
||||
const success = await model.saveFileContent(filePath, fileContent);
|
||||
if (success) {
|
||||
output.appendLine(`[Squirrel] 文件 ${filePath} 保存成功`);
|
||||
provider.refresh();
|
||||
// 更新函数缓存
|
||||
await functionExtractor.updateFileCache(model, filePath);
|
||||
// 发送文件内容到本地C++服务
|
||||
try {
|
||||
const sendSuccess = await (0, localClient_1.sendFileToCppService)(filePath, fileContent);
|
||||
if (sendSuccess) {
|
||||
output.appendLine(`[Squirrel] 文件 ${filePath} 已发送到C++服务`);
|
||||
// 先发送文件内容到本地C++服务
|
||||
try {
|
||||
const sendSuccess = await (0, localClient_1.sendFileToCppService)(filePath, fileContent);
|
||||
if (sendSuccess) {
|
||||
output.appendLine(`[Squirrel] 文件 ${filePath} 已发送到C++服务`);
|
||||
// C++服务返回200后,继续执行保存到服务器
|
||||
const success = await model.saveFileContent(filePath, fileContent);
|
||||
if (success) {
|
||||
output.appendLine(`[Squirrel] 文件 ${filePath} 保存成功`);
|
||||
provider.refresh();
|
||||
// 更新函数缓存
|
||||
await functionExtractor.updateFileCache(model, filePath);
|
||||
}
|
||||
else {
|
||||
output.appendLine(`[Squirrel] 文件 ${filePath} 发送到C++服务失败`);
|
||||
output.appendLine(`[Squirrel] 文件 ${filePath} 保存到服务器失败`);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
output.appendLine(`[Squirrel] 发送文件到C++服务时发生错误: ${error}`);
|
||||
else {
|
||||
output.appendLine(`[Squirrel] 文件 ${filePath} 发送到C++服务失败,跳过保存到服务器`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
output.appendLine(`[Squirrel] 文件 ${filePath} 保存失败`);
|
||||
catch (error) {
|
||||
output.appendLine(`[Squirrel] 发送文件到C++服务时发生错误: ${error}`);
|
||||
output.appendLine(`[Squirrel] 跳过保存文件 ${filePath} 到服务器`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
2
dist/extension.js.map
vendored
2
dist/extension.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user