mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01:00
🎨 文件夹不编入路径映射
This commit is contained in:
parent
d00ef7d2e4
commit
603da6e948
1 changed files with 14 additions and 16 deletions
|
|
@ -288,7 +288,7 @@ func SyncData(boot, exit, byHand bool) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
//util.LogInfof("sync [cloud=%d, local=%d] downloading...", cloudSyncVer, syncConf.SyncVer)
|
//util.LogInfof("sync [cloud=%d, local=%d] downloading...", cloudSyncVer, syncConf.SyncVer)
|
||||||
|
|
||||||
// 使用索引文件进行解密验证 https://github.com/siyuan-note/siyuan/issues/3789
|
// 使用路径映射文件进行解密验证 https://github.com/siyuan-note/siyuan/issues/3789
|
||||||
var tmpFetchedFiles int
|
var tmpFetchedFiles int
|
||||||
var tmpTransferSize uint64
|
var tmpTransferSize uint64
|
||||||
err = ossDownload0(util.TempDir+"/sync", "sync/"+Conf.Sync.CloudName, "/"+pathJSON, &tmpFetchedFiles, &tmpTransferSize, boot || exit)
|
err = ossDownload0(util.TempDir+"/sync", "sync/"+Conf.Sync.CloudName, "/"+pathJSON, &tmpFetchedFiles, &tmpTransferSize, boot || exit)
|
||||||
|
|
@ -783,7 +783,7 @@ func prepareSyncData(passwd string, unchangedDataList map[string]bool) (encrypte
|
||||||
}
|
}
|
||||||
|
|
||||||
ctime := map[string]time.Time{}
|
ctime := map[string]time.Time{}
|
||||||
metaJSON := map[string]string{}
|
meta := map[string]string{}
|
||||||
filepath.Walk(util.DataDir, func(path string, info fs.FileInfo, _ error) error {
|
filepath.Walk(util.DataDir, func(path string, info fs.FileInfo, _ error) error {
|
||||||
if util.DataDir == path || nil == info {
|
if util.DataDir == path || nil == info {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -803,7 +803,9 @@ func prepareSyncData(passwd string, unchangedDataList map[string]bool) (encrypte
|
||||||
if !strings.HasPrefix(plainP, ".siyuan") { // 配置目录下都用明文,其他文件需要映射文件名
|
if !strings.HasPrefix(plainP, ".siyuan") { // 配置目录下都用明文,其他文件需要映射文件名
|
||||||
p = pathSha256Short(p, string(os.PathSeparator))
|
p = pathSha256Short(p, string(os.PathSeparator))
|
||||||
}
|
}
|
||||||
metaJSON[filepath.ToSlash(p)] = filepath.ToSlash(plainP)
|
if !isDir {
|
||||||
|
meta[filepath.ToSlash(p)] = filepath.ToSlash(plainP)
|
||||||
|
}
|
||||||
|
|
||||||
// 如果不是新增或者修改则跳过
|
// 如果不是新增或者修改则跳过
|
||||||
if unchangedDataList[path] {
|
if unchangedDataList[path] {
|
||||||
|
|
@ -816,9 +818,6 @@ func prepareSyncData(passwd string, unchangedDataList map[string]bool) (encrypte
|
||||||
if err = os.MkdirAll(p, 0755); nil != err {
|
if err = os.MkdirAll(p, 0755); nil != err {
|
||||||
return io.EOF
|
return io.EOF
|
||||||
}
|
}
|
||||||
if fi, err0 := os.Stat(path); nil == err0 {
|
|
||||||
ctime[p] = fi.ModTime()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if err = os.MkdirAll(filepath.Dir(p), 0755); nil != err {
|
if err = os.MkdirAll(filepath.Dir(p), 0755); nil != err {
|
||||||
return io.EOF
|
return io.EOF
|
||||||
|
|
@ -873,14 +872,14 @@ func prepareSyncData(passwd string, unchangedDataList map[string]bool) (encrypte
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
path = strings.TrimPrefix(path, encryptedDataDir+string(os.PathSeparator))
|
|
||||||
path = filepath.ToSlash(path)
|
|
||||||
if _, ok := metaJSON[path]; !ok {
|
|
||||||
util.LogErrorf("not found sync path in meta [%s]", path)
|
|
||||||
return errors.New(Conf.Language(27))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !info.IsDir() {
|
if !info.IsDir() {
|
||||||
|
path = strings.TrimPrefix(path, encryptedDataDir+string(os.PathSeparator))
|
||||||
|
path = filepath.ToSlash(path)
|
||||||
|
if _, ok := meta[path]; !ok {
|
||||||
|
util.LogErrorf("not found sync path in meta [%s]", path)
|
||||||
|
return errors.New(Conf.Language(27))
|
||||||
|
}
|
||||||
|
|
||||||
upsertList["/"+path] = true
|
upsertList["/"+path] = true
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -889,7 +888,7 @@ func prepareSyncData(passwd string, unchangedDataList map[string]bool) (encrypte
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := gulu.JSON.MarshalJSON(metaJSON)
|
data, err := gulu.JSON.MarshalJSON(meta)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -898,8 +897,7 @@ func prepareSyncData(passwd string, unchangedDataList map[string]bool) (encrypte
|
||||||
util.LogErrorf("encrypt file failed: %s", err)
|
util.LogErrorf("encrypt file failed: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
meta := filepath.Join(encryptedDataDir, pathJSON)
|
if err = os.WriteFile(filepath.Join(encryptedDataDir, pathJSON), data, 0644); nil != err {
|
||||||
if err = os.WriteFile(meta, data, 0644); nil != err {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue