mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
Merge pull request #555 from selfhost-alt/handle-corrupted-backups
Handle corrupted backups gracefully and continue loading other backups
This commit is contained in:
commit
a482e5d316
@ -131,8 +131,21 @@ class BackupManager {
|
|||||||
var filename = filesInDir[i]
|
var filename = filesInDir[i]
|
||||||
if (filename.endsWith('.audiobookshelf')) {
|
if (filename.endsWith('.audiobookshelf')) {
|
||||||
var fullFilePath = Path.join(this.BackupPath, filename)
|
var fullFilePath = Path.join(this.BackupPath, filename)
|
||||||
const zip = new StreamZip.async({ file: fullFilePath })
|
|
||||||
const data = await zip.entryData('details')
|
let zip = null
|
||||||
|
let data = null
|
||||||
|
try {
|
||||||
|
zip = new StreamZip.async({ file: fullFilePath })
|
||||||
|
data = await zip.entryData('details')
|
||||||
|
} catch (error) {
|
||||||
|
if (error.message === "Bad archive") {
|
||||||
|
Logger.warn(`[BackupManager] Backup appears to be corrupted: ${fullFilePath}`)
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var details = data.toString('utf8').split('\n')
|
var details = data.toString('utf8').split('\n')
|
||||||
|
|
||||||
var backup = new Backup({ details, fullPath: fullFilePath })
|
var backup = new Backup({ details, fullPath: fullFilePath })
|
||||||
|
Loading…
Reference in New Issue
Block a user