修复某些歌曲无法下载的问题

pull/930/merge
lyswhut 2022-02-13 14:17:38 +08:00
parent c48921990d
commit c891ed81e1
3 changed files with 14 additions and 3 deletions

View File

@ -14,6 +14,7 @@
- 修复修改列表名时无法使用`Ctrl`键的问题 - 修复修改列表名时无法使用`Ctrl`键的问题
- 修复wy源某些歌曲获取歌词翻译的问题处理 - 修复wy源某些歌曲获取歌词翻译的问题处理
- 修复下载功能的歌词换源时会进入死循环的问题 - 修复下载功能的歌词换源时会进入死循环的问题
- 修复某些歌曲无法下载的问题
### 其他 ### 其他

View File

@ -439,6 +439,14 @@ const actions = {
dispatch('startTask') dispatch('startTask')
return return
} }
if (err.message?.startsWith('Resume failed')) {
fs.unlink(downloadInfo.metadata.filePath, err => {
if (err) return commit('onError', { downloadInfo, errorMsg: '删除不匹配的文件失败:' + err.message })
dls[downloadInfo.key].start()
commit('setStatusText', { downloadInfo, text: '正在重试' })
})
return
}
if (err.code == 'ENOTFOUND') { if (err.code == 'ENOTFOUND') {
commit('onError', { downloadInfo, errorMsg: '链接失效' }) commit('onError', { downloadInfo, errorMsg: '链接失效' })
refreshUrl.call(_this, commit, downloadInfo, rootState.setting.download.isUseOtherSource) refreshUrl.call(_this, commit, downloadInfo, rootState.setting.download.isUseOtherSource)
@ -562,6 +570,7 @@ const actions = {
filePath: path.join(rootState.setting.download.savePath, downloadInfo.metadata.fileName), filePath: path.join(rootState.setting.download.savePath, downloadInfo.metadata.fileName),
}) })
dl.updateSaveInfo(rootState.setting.download.savePath, downloadInfo.metadata.fileName) dl.updateSaveInfo(rootState.setting.download.savePath, downloadInfo.metadata.fileName)
if (tryNum[downloadInfo.key]) tryNum[downloadInfo.key] = 0
try { try {
await dl.start() await dl.start()
} catch (error) { } catch (error) {

View File

@ -153,7 +153,7 @@ class Task extends EventEmitter {
__initDownload(response) { __initDownload(response) {
this.progress.total = parseInt(response.headers['content-length'] || 0) this.progress.total = parseInt(response.headers['content-length'] || 0)
let options = {} let options = {}
let isResumable = this.options.forceResume || response.headers['accept-ranges'] !== 'none' let isResumable = this.options.forceResume || response.headers['accept-ranges'] !== 'none' || (typeof response.headers['accept-ranges'] == 'string' && parseInt(response.headers['accept-ranges'].replace(/^bytes=(\d+)/, '$1')) > 0)
if (isResumable) { if (isResumable) {
options.flags = 'a' options.flags = 'a'
if (this.progress.downloaded) this.progress.total -= 10 if (this.progress.downloaded) this.progress.total -= 10
@ -227,8 +227,9 @@ class Task extends EventEmitter {
if (this.resumeLastChunk) { if (this.resumeLastChunk) {
chunk = this.__handleDiffChunk(chunk) chunk = this.__handleDiffChunk(chunk)
if (!chunk) { if (!chunk) {
this.__handleStop().finally(() => {
this.__handleError(new Error('Resume failed, response chunk does not match.')) this.__handleError(new Error('Resume failed, response chunk does not match.'))
this.stop() })
return return
} }
} }