fix the issue of webdav local backup file storage (#5643)

fix the issue of unlimited webdav local backup file storage
This commit is contained in:
Starsky Wong 2025-05-04 13:16:06 +08:00 committed by GitHub
parent 094d369187
commit 6e9bde6b6d

View File

@ -286,9 +286,18 @@ class BackupManager {
const filename = webdavConfig.fileName || 'cherry-studio.backup.zip'
const backupedFilePath = await this.backup(_, filename, data)
const webdavClient = new WebDav(webdavConfig)
return await webdavClient.putFileContents(filename, fs.createReadStream(backupedFilePath), {
overwrite: true
})
try {
const result = await webdavClient.putFileContents(filename, fs.createReadStream(backupedFilePath), {
overwrite: true
})
// 上传成功后删除本地备份文件
await fs.remove(backupedFilePath)
return result
} catch (error) {
// 上传失败时也删除本地临时文件
await fs.remove(backupedFilePath).catch(() => {})
throw error
}
}
async restoreFromWebdav(_: Electron.IpcMainInvokeEvent, webdavConfig: WebDavConfig) {