fix: address code review - sanitize error output, fix timezone calc, narrow git add scope [skip ci]
Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/bc1b54c6-5276-4d00-8ea5-5e8c3c2bef38
This commit is contained in:
parent
0d842e52df
commit
368a7f139f
|
|
@ -68,6 +68,7 @@ jobs:
|
|||
run: |
|
||||
git config user.name "zhuyuan-bot"
|
||||
git config user.email "zhuyuan@guanghulab.com"
|
||||
git add config/gdrive-tokens.json grid-db/logs/
|
||||
git add config/gdrive-tokens.json
|
||||
git add -f grid-db/logs/token-alert.json 2>/dev/null || true
|
||||
git diff --cached --quiet || git commit -m "auto: Token health check $(date -u +%Y-%m-%dT%H:%M:%SZ) [skip ci]"
|
||||
git push
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ jobs:
|
|||
run: |
|
||||
git config user.name "zhuyuan-bot"
|
||||
git config user.email "zhuyuan@guanghulab.com"
|
||||
git add config/gdrive-tokens.json grid-db/logs/
|
||||
git add config/gdrive-tokens.json
|
||||
git add -f grid-db/logs/token-alert.json 2>/dev/null || true
|
||||
git diff --cached --quiet || git commit -m "auto: Token renewal $(date -u +%Y-%m-%dT%H:%M:%SZ) [skip ci]"
|
||||
git push
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@
|
|||
|
||||
function isInHibernation() {
|
||||
const now = new Date();
|
||||
// 转换为北京时间
|
||||
const cst = new Date(now.toLocaleString('en-US', { timeZone: 'Asia/Shanghai' }));
|
||||
// 转换为北京时间(UTC+8),使用 UTC 偏移计算避免 locale 差异
|
||||
const utcMs = now.getTime() + now.getTimezoneOffset() * 60 * 1000;
|
||||
const cst = new Date(utcMs + 8 * 60 * 60 * 1000);
|
||||
const day = cst.getDay(); // 0=周日, 6=周六
|
||||
const hour = cst.getHours();
|
||||
const minute = cst.getMinutes();
|
||||
|
|
|
|||
|
|
@ -104,8 +104,8 @@ async function main() {
|
|||
console.log(` ✅ 刷新成功!新过期时间: ${token.expires_at}`);
|
||||
results.renewed.push(token.user_id);
|
||||
} else {
|
||||
// Google 有时不返回新的 refresh_token
|
||||
console.log(` ⚠️ Google 未返回新 refresh_token,Token 可能仍然有效但无法续期`);
|
||||
// Google 有时不返回新的 refresh_token(access_type 非 offline 或非首次授权时常见)
|
||||
console.log(` ⚠️ Google 未返回新 refresh_token,需人类重新授权(access_type=offline + prompt=consent)`);
|
||||
token.status = 'expiring';
|
||||
registry.renew_log.push({
|
||||
user_id: token.user_id,
|
||||
|
|
@ -202,7 +202,7 @@ async function refreshOAuth2Token(refreshToken) {
|
|||
resolve(json);
|
||||
}
|
||||
} catch (e) {
|
||||
reject(new Error(`Invalid response from Google: ${data.substring(0, 200)}`));
|
||||
reject(new Error('Invalid JSON response from Google OAuth2 endpoint'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue