Plan Phase C and D implementation

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/a581dc42-267b-44e1-b669-6ad503a47f49
This commit is contained in:
copilot-swe-agent[bot] 2026-03-23 04:08:22 +00:00
parent ec8f85522a
commit d8810d1546
2 changed files with 15 additions and 4 deletions

View File

@ -72,7 +72,9 @@ function processInbox() {
var timestamp = Utilities.formatDate(
new Date(), 'Asia/Shanghai', 'yyyyMMdd-HHmmss'
);
var safeName = file.getName().replace(/[^a-zA-Z0-9\-_]/g, '');
var safeName = file.getName().replace(/[^a-zA-Z0-9.\-_]/g, '');
// Strip any existing extension, then add .json
safeName = safeName.replace(/\.[^.]+$/, '');
var filename = timestamp + '-' + safeName + '.json';
// 写入 GitHub 仓库
@ -161,7 +163,7 @@ function writeToGitHub(token, filePath, content) {
+ CONFIG.GITHUB_REPO + '/contents/' + filePath;
var payload = {
message: 'auto: Gemini inbox via Drive bridge [skip ci]',
message: 'auto: Gemini inbox via Drive bridge (' + filePath.split('/').pop() + ') [skip ci]',
content: Utilities.base64Encode(content, Utilities.Charset.UTF_8),
branch: CONFIG.GITHUB_BRANCH
};

View File

@ -65,6 +65,13 @@ function collectFiles(dirPath, recursive) {
return results;
}
/**
* 转义 Drive API 查询中的单引号
*/
function escapeQuery(str) {
return str.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
}
/**
* Drive 中查找或创建文件夹按路径逐级创建
*/
@ -73,7 +80,8 @@ async function getOrCreateDriveFolder(drive, parentId, folderPath) {
let currentParentId = parentId;
for (const part of parts) {
const query = `name='${part}' and '${currentParentId}' in parents and mimeType='application/vnd.google-apps.folder' and trashed=false`;
const safePart = escapeQuery(part);
const query = `name='${safePart}' and '${currentParentId}' in parents and mimeType='application/vnd.google-apps.folder' and trashed=false`;
const res = await drive.files.list({
q: query,
fields: 'files(id, name)',
@ -103,7 +111,8 @@ async function getOrCreateDriveFolder(drive, parentId, folderPath) {
* Drive 目标文件夹中查找同名文件
*/
async function findFileInDrive(drive, folderId, fileName) {
const query = `name='${fileName}' and '${folderId}' in parents and trashed=false`;
const safeFileName = escapeQuery(fileName);
const query = `name='${safeFileName}' and '${folderId}' in parents and trashed=false`;
const res = await drive.files.list({
q: query,
fields: 'files(id, name, md5Checksum)',