fix(BackupManager): add content length to WebDAV file upload options (#6977)

feat(BackupManager): add content length to WebDAV file upload options
This commit is contained in:
beyondkmp 2025-06-08 12:36:20 +08:00 committed by GitHub
parent 3f35ad998c
commit c6a965028e

View File

@ -295,10 +295,12 @@ class BackupManager {
async backupToWebdav(_: Electron.IpcMainInvokeEvent, data: string, webdavConfig: WebDavConfig) {
const filename = webdavConfig.fileName || 'cherry-studio.backup.zip'
const backupedFilePath = await this.backup(_, filename, data, undefined, webdavConfig.skipBackupFile)
const contentLength = (await fs.stat(backupedFilePath)).size
const webdavClient = new WebDav(webdavConfig)
try {
const result = await webdavClient.putFileContents(filename, fs.createReadStream(backupedFilePath), {
overwrite: true
overwrite: true,
contentLength
})
// 上传成功后删除本地备份文件
await fs.remove(backupedFilePath)