v0.3.14: cookie_uid/空间修复 + checkin/cleanup统一走getter解密

修复:
- testCloudConnection: 验证成功后更新cookie_uid和storageUsed
- 5个getter SELECT添加cookie_uid列
- checkin.service: dailyCheckIn改用getCloudConfigById(自带解密)
- cleanup.service: getActiveCleanupConfigs改用getActiveCloudConfigs(自带解密)
- checkin/cleanup不再直接查DB绕开解密
This commit is contained in:
2026-05-17 15:49:43 +08:00
parent eebf4b6c97
commit ea03ff2203
5 changed files with 17 additions and 19 deletions

View File

@@ -1 +1 @@
0.3.13
0.3.14

View File

@@ -8,9 +8,7 @@ export async function dailyCheckIn(id: number): Promise<{
signedDays?: number;
}> {
const db = getDb();
const config = db.prepare(
'SELECT * FROM cloud_configs WHERE id = ?'
).get(id) as CloudConfig | undefined;
const config = getCloudConfigById(id);
if (!config || !config.cookie) {
return { success: false, message: '未找到该网盘的有效配置' };
}

View File

@@ -2,6 +2,7 @@ import { getDb } from '../database/database';
import { getSystemConfig, updateSystemConfig } from '../admin/system-config.service';
import { formatLocalDate, formatLocalDateTime } from '../utils/time';
import { QuarkDriver } from './drivers/quark.driver';
import { CloudConfig, getActiveCloudConfigs } from './credential.service';
import { BaiduDriver } from './drivers/baidu.driver';
// ═══════════════════════════════════════════════════════════════════════════
@@ -63,12 +64,9 @@ interface CleanupStats {
}
/** Get all active cloud configs (any type). Used by the orchestrator. */
function getActiveCleanupConfigs(): Array<{ id: number; cloud_type: string; cookie: string; nickname?: string }> {
const db = getDb();
return db.prepare(
`SELECT id, cloud_type, cookie, nickname FROM cloud_configs
WHERE is_active = 1 AND cookie IS NOT NULL AND cookie != ''`
).all() as Array<{ id: number; cloud_type: string; cookie: string; nickname?: string }>;
function getActiveCleanupConfigs() {
const configs = getActiveCloudConfigs();
return configs.filter((c): c is CloudConfig & { cookie: string } => !!c.cookie);
}
/**

View File

@@ -43,7 +43,7 @@ function extractCookieUid(cookie: string): string {
export function getCloudConfigs(): CloudConfig[] {
const db = getDb();
const rows = db.prepare(
`SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total,
`SELECT id, cloud_type, cookie, nickname, is_active, cookie_uid, storage_used, storage_total,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at, verification_status
FROM cloud_configs ORDER BY id ASC`
@@ -55,7 +55,7 @@ export function getCloudConfigs(): CloudConfig[] {
export function getAvailableClouds(): CloudConfig[] {
const db = getDb();
const rows = db.prepare(
`SELECT id, cloud_type, nickname, is_active, storage_used, storage_total,
`SELECT id, cloud_type, nickname, is_active, cookie_uid, storage_used, storage_total,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at
FROM cloud_configs WHERE is_active = 1 ORDER BY id ASC`
@@ -68,7 +68,7 @@ export function getAvailableClouds(): CloudConfig[] {
export function getCloudConfigByType(cloudType: string): CloudConfig | undefined {
const db = getDb();
const cfg = db.prepare(
`SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total,
`SELECT id, cloud_type, cookie, nickname, is_active, cookie_uid, storage_used, storage_total,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at, verification_status
FROM cloud_configs WHERE cloud_type = ? AND is_active = 1
@@ -81,7 +81,7 @@ export function getCloudConfigByType(cloudType: string): CloudConfig | undefined
export function getCloudConfigById(id: number): CloudConfig | undefined {
const db = getDb();
const cfg = db.prepare(
`SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total,
`SELECT id, cloud_type, cookie, nickname, is_active, cookie_uid, storage_used, storage_total,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at, verification_status
FROM cloud_configs WHERE id = ?`
@@ -94,7 +94,7 @@ export function getCloudConfigById(id: number): CloudConfig | undefined {
export function getActiveCloudConfigs(): CloudConfig[] {
const db = getDb();
const rows = db.prepare(
`SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total,
`SELECT id, cloud_type, cookie, nickname, is_active, cookie_uid, storage_used, storage_total,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at
FROM cloud_configs WHERE is_active = 1
@@ -162,7 +162,7 @@ export function saveCloudConfig(data: {
const savedId = data.id || (db.prepare('SELECT last_insert_rowid() as id').get() as any).id;
return db.prepare(
`SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total,
`SELECT id, cloud_type, cookie, nickname, is_active, cookie_uid, storage_used, storage_total,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at
FROM cloud_configs WHERE id = ?`
@@ -246,6 +246,7 @@ export async function testCloudConnection(id: number): Promise<{
if (valid) {
nickname = config.nickname || (await fetchQuarkNickname(cookie)) || '夸克网盘';
const storage = await driver.getStorageInfoQuick();
storageUsed = (storage.used !== '-' && storage.used !== '0 B') ? storage.used : (config.storage_used || '');
storageTotal = (storage.total !== '-' && storage.total !== '0 B') ? storage.total : (config.storage_total || '');
}
}
@@ -258,9 +259,10 @@ export async function testCloudConnection(id: number): Promise<{
return { success: false, message: '连接失败Cookie 无效或已过期,或网络暂时异常' };
}
const cookieUid = extractCookieUid(cookie);
db.prepare(
`UPDATE cloud_configs SET nickname = ?, storage_total = ?, storage_used = ?, is_active = 1, verification_status = 'valid', updated_at = ? WHERE id = ?`
).run(nickname, storageTotal, storageUsed, localTimestamp(), id);
`UPDATE cloud_configs SET nickname = ?, storage_total = ?, storage_used = ?, cookie_uid = ?, is_active = 1, verification_status = 'valid', updated_at = ? WHERE id = ?`
).run(nickname, storageTotal, storageUsed, cookieUid, localTimestamp(), id);
return {
success: true,