mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 12:51:26 +08:00
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:
parent
094d369187
commit
6e9bde6b6d
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user