feat: improve upload resilience and release 0.1.23
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user