Skip to content

Commit

Permalink
Merge pull request #20 from jbwfu/fix/webdav-unix-path-support
Browse files Browse the repository at this point in the history
Update plugin-sync-configuration-webdav.js
  • Loading branch information
Ayideyia authored Nov 12, 2024
2 parents eed6cb3 + 5464f48 commit c857074
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugins/Generic/plugin-sync-configuration-webdav.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ const Sync = async () => {
const files = JSON.parse(content)

let failed = false

const isWindows = Plugins.useEnvStore().env.os == 'windows'
const separator = isWindows ? '\\' : '/'

const _files = Object.keys(files)
for (let i = 0; i < _files.length; i++) {
const file = _files[i]
const encrypted = files[file].content
const processedFile = file.replaceAll(/\//g, separator)
.replaceAll(/\\/g, separator)
update(`正在恢复文件...[ ${i + 1}/${_files.length} ]`, 'info')
try {
await Plugins.Writefile(file, decrypt(encrypted))
await Plugins.Writefile(processedFile, decrypt(encrypted))
} catch (error) {
if (error === '解密失败') {
failed = true
Expand Down Expand Up @@ -102,7 +107,7 @@ const Backup = async () => {
try {
const text = await Plugins.ignoredError(Plugins.Readfile, file)
if (text) {
filesMap[file.replaceAll('/', '\\')] = { content: encrypt(text) }
filesMap[file] = { content: encrypt(text) }
}
} catch (error) {
console.log(error)
Expand Down

0 comments on commit c857074

Please sign in to comment.