修改保存逻辑:先发送文件到本地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:
22
dist/extension.js
vendored
22
dist/extension.js
vendored
@@ -134,28 +134,30 @@ function activate(context) {
|
|||||||
if (doc.uri.scheme === 'squirrel') {
|
if (doc.uri.scheme === 'squirrel') {
|
||||||
const filePath = doc.uri.path.substring(1); // 去掉开头的 '/'
|
const filePath = doc.uri.path.substring(1); // 去掉开头的 '/'
|
||||||
const fileContent = doc.getText();
|
const fileContent = doc.getText();
|
||||||
|
// 先发送文件内容到本地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);
|
const success = await model.saveFileContent(filePath, fileContent);
|
||||||
if (success) {
|
if (success) {
|
||||||
output.appendLine(`[Squirrel] 文件 ${filePath} 保存成功`);
|
output.appendLine(`[Squirrel] 文件 ${filePath} 保存成功`);
|
||||||
provider.refresh();
|
provider.refresh();
|
||||||
// 更新函数缓存
|
// 更新函数缓存
|
||||||
await functionExtractor.updateFileCache(model, filePath);
|
await functionExtractor.updateFileCache(model, filePath);
|
||||||
// 发送文件内容到本地C++服务
|
|
||||||
try {
|
|
||||||
const sendSuccess = await (0, localClient_1.sendFileToCppService)(filePath, fileContent);
|
|
||||||
if (sendSuccess) {
|
|
||||||
output.appendLine(`[Squirrel] 文件 ${filePath} 已发送到C++服务`);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
output.appendLine(`[Squirrel] 文件 ${filePath} 发送到C++服务失败`);
|
output.appendLine(`[Squirrel] 文件 ${filePath} 保存到服务器失败`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
output.appendLine(`[Squirrel] 文件 ${filePath} 发送到C++服务失败,跳过保存到服务器`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
output.appendLine(`[Squirrel] 发送文件到C++服务时发生错误: ${error}`);
|
output.appendLine(`[Squirrel] 发送文件到C++服务时发生错误: ${error}`);
|
||||||
}
|
output.appendLine(`[Squirrel] 跳过保存文件 ${filePath} 到服务器`);
|
||||||
}
|
|
||||||
else {
|
|
||||||
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
@@ -142,6 +142,14 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
if (doc.uri.scheme === 'squirrel') {
|
if (doc.uri.scheme === 'squirrel') {
|
||||||
const filePath = doc.uri.path.substring(1); // 去掉开头的 '/'
|
const filePath = doc.uri.path.substring(1); // 去掉开头的 '/'
|
||||||
const fileContent = doc.getText();
|
const fileContent = doc.getText();
|
||||||
|
|
||||||
|
// 先发送文件内容到本地C++服务
|
||||||
|
try {
|
||||||
|
const sendSuccess = await sendFileToCppService(filePath, fileContent);
|
||||||
|
if (sendSuccess) {
|
||||||
|
output.appendLine(`[Squirrel] 文件 ${filePath} 已发送到C++服务`);
|
||||||
|
|
||||||
|
// C++服务返回200后,继续执行保存到服务器
|
||||||
const success = await model.saveFileContent(filePath, fileContent);
|
const success = await model.saveFileContent(filePath, fileContent);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
@@ -150,20 +158,15 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
// 更新函数缓存
|
// 更新函数缓存
|
||||||
await functionExtractor.updateFileCache(model, filePath);
|
await functionExtractor.updateFileCache(model, filePath);
|
||||||
|
|
||||||
// 发送文件内容到本地C++服务
|
|
||||||
try {
|
|
||||||
const sendSuccess = await sendFileToCppService(filePath, fileContent);
|
|
||||||
if (sendSuccess) {
|
|
||||||
output.appendLine(`[Squirrel] 文件 ${filePath} 已发送到C++服务`);
|
|
||||||
} else {
|
} else {
|
||||||
output.appendLine(`[Squirrel] 文件 ${filePath} 发送到C++服务失败`);
|
output.appendLine(`[Squirrel] 文件 ${filePath} 保存到服务器失败`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
output.appendLine(`[Squirrel] 文件 ${filePath} 发送到C++服务失败,跳过保存到服务器`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
output.appendLine(`[Squirrel] 发送文件到C++服务时发生错误: ${error}`);
|
output.appendLine(`[Squirrel] 发送文件到C++服务时发生错误: ${error}`);
|
||||||
}
|
output.appendLine(`[Squirrel] 跳过保存文件 ${filePath} 到服务器`);
|
||||||
} else {
|
|
||||||
output.appendLine(`[Squirrel] 文件 ${filePath} 保存失败`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user