feat: improve upload resilience and release 0.1.23

This commit is contained in:
2026-02-20 20:21:42 +08:00
parent 6618de1aed
commit 01384a2215
9 changed files with 435 additions and 115 deletions

View File

@@ -2512,8 +2512,9 @@ const UploadSessionDB = {
return db.prepare('SELECT * FROM upload_sessions WHERE session_id = ?').get(sid);
},
findActiveForResume(userId, targetPath, fileSize, fileHash = null) {
findActiveForResume(userId, storageType, targetPath, fileSize, fileHash = null) {
const uid = Number(userId);
const safeStorageType = storageType === 'local' ? 'local' : 'oss';
const safePath = typeof targetPath === 'string' ? targetPath : '';
const size = Math.floor(Number(fileSize) || 0);
const hash = typeof fileHash === 'string' ? fileHash.trim() : '';
@@ -2526,6 +2527,7 @@ const UploadSessionDB = {
SELECT *
FROM upload_sessions
WHERE user_id = ?
AND storage_type = ?
AND target_path = ?
AND file_size = ?
AND status = 'active'
@@ -2533,20 +2535,21 @@ const UploadSessionDB = {
AND COALESCE(file_hash, '') = ?
ORDER BY updated_at DESC, created_at DESC
LIMIT 1
`).get(Math.floor(uid), safePath, size, hash);
`).get(Math.floor(uid), safeStorageType, safePath, size, hash);
}
return db.prepare(`
SELECT *
FROM upload_sessions
WHERE user_id = ?
AND storage_type = ?
AND target_path = ?
AND file_size = ?
AND status = 'active'
AND expires_at > datetime('now', 'localtime')
ORDER BY updated_at DESC, created_at DESC
LIMIT 1
`).get(Math.floor(uid), safePath, size);
`).get(Math.floor(uid), safeStorageType, safePath, size);
},
updateProgress(sessionId, uploadedChunks = [], uploadedBytes = 0, expiresAt = null) {