🐛 Fix(custom): fix webdav backup bug for custom path close #347

This commit is contained in:
Kuingsmile
2025-07-18 17:00:58 +08:00
parent 2b23890a21
commit 64747887e1
5 changed files with 32 additions and 2 deletions

View File

@@ -141,7 +141,15 @@ async function uploadLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
}
const client = createClient(webdavEndpointF, options)
const fileContent = fs.readFileSync(localFilePath)
const remoteFilePath = webdavSavePath ? path.join(webdavSavePath, fileName) : fileName
const remoteFilePath = webdavSavePath
? `${webdavSavePath}/${fileName}`.replace(/^\/+|\/+$/g, '').replace(/\/\/+/g, '/')
: fileName
console.log('remoteFilePath', remoteFilePath)
const remoteDir = path.dirname(remoteFilePath)
console.log('remoteDir', remoteDir)
if (remoteDir !== '/') {
await client.createDirectory(remoteDir, { recursive: true })
}
await client.putFileContents(remoteFilePath, fileContent, { overwrite: true })
return true
}
@@ -255,7 +263,13 @@ async function updateLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
}
const client = createClient(webdavEndpointF, options)
const fileContent = fs.readFileSync(localFilePath)
const remoteFilePath = webdavSavePath ? path.join(webdavSavePath, fileName) : fileName
const remoteFilePath = webdavSavePath
? `${webdavSavePath}/${fileName}`.replace(/^\/+|\/+$/g, '').replace(/\/\/+/g, '/')
: fileName
const remoteDir = path.dirname(remoteFilePath)
if (remoteDir !== '/') {
await client.createDirectory(remoteDir, { recursive: true })
}
await client.putFileContents(remoteFilePath, fileContent, { overwrite: true })
return true
}

View File

@@ -1,4 +1,5 @@
interface ILocales {
LANG_DISPLAY_LABEL: string
ABOUT: string
OPEN_MAIN_WINDOW: string
OPEN_MINI_WINDOW: string
@@ -9,6 +10,7 @@ interface ILocales {
UPLOAD_FAILED: string
UPLOAD_PROGRESS: string
OPERATION_SUCCEED: string
OPERATION_FAILED: string
UPLOADING: string
QUICK_UPLOAD: string
UPLOAD_BY_CLIPBOARD: string
@@ -925,6 +927,8 @@ interface ILocales {
TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT: string
TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP: string
TIPS_PICGO_BACKUP_FILE_VERSION: string
TIPS_SHORTCUT_MODIFIED_SUCCEED: string
TIPS_SHORTCUT_MODIFIED_CONFLICT: string
TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR: string
TIPS_FIND_NEW_VERSION: string
UPDATE_DOWNLOADED: string