Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-06-05 11:14:41 +08:00
commit eb78e27d9c
6 changed files with 54 additions and 339 deletions

View file

@ -4,7 +4,7 @@
"Properties": {
"id": "20210721112211-fwc1x43",
"title": "Data Backup",
"updated": "20220114235532"
"updated": "20220605010124"
},
"Children": [
{
@ -586,7 +586,7 @@
"ListData": {},
"Properties": {
"id": "20210721113518-flygugq",
"updated": "20210721113518"
"updated": "20220605010124"
},
"Children": [
{
@ -597,117 +597,21 @@
"Marker": "Kg=="
},
"Properties": {
"id": "20210721113518-t2bu4ls"
"id": "20210721113518-t2bu4ls",
"updated": "20220605010124"
},
"Children": [
{
"ID": "20210721113518-vu6mx99",
"Type": "NodeParagraph",
"Properties": {
"id": "20210721113518-vu6mx99"
"id": "20210721113518-vu6mx99",
"updated": "20220605010124"
},
"Children": [
{
"Type": "NodeText",
"Data": "The backup data is stored in the "
},
{
"Type": "NodeCodeSpan",
"Data": "code",
"Children": [
{
"Type": "NodeCodeSpanOpenMarker"
},
{
"Type": "NodeCodeSpanContent",
"Data": "workspace/backup/"
},
{
"Type": "NodeCodeSpanCloseMarker"
}
]
},
{
"Type": "NodeText",
"Data": " folder by default, and the location can be modified"
}
]
}
]
},
{
"ID": "20210721113518-z0rcq4e",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20210721113518-z0rcq4e"
},
"Children": [
{
"ID": "20210721113518-3l5b6ep",
"Type": "NodeParagraph",
"Properties": {
"id": "20210721113518-3l5b6ep"
},
"Children": [
{
"Type": "NodeText",
"Data": "Do not use a third-party synchronization disk to synchronize the folder, otherwise it may cause data damage"
}
]
}
]
},
{
"ID": "20210721113518-0gpgg0n",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20210721113518-0gpgg0n"
},
"Children": [
{
"ID": "20210721113518-kt4w5p5",
"Type": "NodeParagraph",
"Properties": {
"id": "20210721113518-kt4w5p5"
},
"Children": [
{
"Type": "NodeText",
"Data": "Without changing the password, the data is transferred incrementally"
}
]
}
]
},
{
"ID": "20210721113518-d6loa4f",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20210721113518-d6loa4f"
},
"Children": [
{
"ID": "20210721113518-e0qk31c",
"Type": "NodeParagraph",
"Properties": {
"id": "20210721113518-e0qk31c"
},
"Children": [
{
"Type": "NodeText",
"Data": "The password must be kept in mind, the data cannot be recovered without a password, and the password cannot be cleared or retrieved"
"Data": "Do not use a third-party sync disk and SiYuan backup at the same time, it may cause data damage"
}
]
}

View file

@ -5,7 +5,7 @@
"id": "20201002090451-hb9j8ai",
"title": "数据备份",
"type": "doc",
"updated": "20220114235451"
"updated": "20210525213840"
},
"Children": [
{
@ -589,57 +589,9 @@
"ListData": {},
"Properties": {
"id": "20210524213716-ohh5os5",
"updated": "20210721110355"
"updated": "20210525213840"
},
"Children": [
{
"ID": "20210524213941-e2e360h",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20210524213941-e2e360h",
"updated": "20210721110141"
},
"Children": [
{
"ID": "20210524213941-cam1ja6",
"Type": "NodeParagraph",
"Properties": {
"id": "20210524213941-cam1ja6",
"updated": "20210721110141"
},
"Children": [
{
"Type": "NodeText",
"Data": "备份数据默认存放在 "
},
{
"Type": "NodeCodeSpan",
"Data": "code",
"Children": [
{
"Type": "NodeCodeSpanOpenMarker"
},
{
"Type": "NodeCodeSpanContent",
"Data": "工作空间/backup/"
},
{
"Type": "NodeCodeSpanCloseMarker"
}
]
},
{
"Type": "NodeText",
"Data": " 文件夹下,该位置可修改"
}
]
}
]
},
{
"ID": "20210721110005-0zh6q73",
"Type": "NodeListItem",
@ -649,7 +601,7 @@
},
"Properties": {
"id": "20210721110005-0zh6q73",
"updated": "20210721110315"
"updated": "20220605005935"
},
"Children": [
{
@ -657,68 +609,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20210721110005-34zreuo",
"updated": "20210721110315"
"updated": "20220605005935"
},
"Children": [
{
"Type": "NodeText",
"Data": "请勿使用第三方同步盘同步该文件夹,否则可能会造成数据损坏"
}
]
}
]
},
{
"ID": "20210524214140-o24jy91",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20210524214140-o24jy91",
"updated": "20210721110355"
},
"Children": [
{
"ID": "20210524214140-7obgo1d",
"Type": "NodeParagraph",
"Properties": {
"id": "20210524214140-7obgo1d",
"updated": "20210721110355"
},
"Children": [
{
"Type": "NodeText",
"Data": "在不改变密码的情况下,数据是进行增量传输的"
}
]
}
]
},
{
"ID": "20210721102719-yhk2dq5",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20210721102719-yhk2dq5",
"updated": "20210721102811"
},
"Children": [
{
"ID": "20210721102719-fq9diiz",
"Type": "NodeParagraph",
"Properties": {
"id": "20210721102719-fq9diiz",
"updated": "20210721102811"
},
"Children": [
{
"Type": "NodeText",
"Data": "密码务必牢记,没有密码无法恢复数据,且密码无法清空或找回"
"Data": "请勿同时使用第三方同步盘和思源备份,可能会导致数据损坏"
}
]
}
@ -732,7 +628,8 @@
"Marker": "Kg=="
},
"Properties": {
"id": "20210525213740-3z17tp0"
"id": "20210525213740-3z17tp0",
"updated": "20210525213840"
},
"Children": [
{

View file

@ -4,7 +4,7 @@
"Properties": {
"id": "20211226121413-nznc7x0",
"title": "資料備份",
"updated": "20220114235521"
"updated": "20220605010033"
},
"Children": [
{
@ -588,57 +588,9 @@
"ListData": {},
"Properties": {
"id": "20211226121432-vk1p2ti",
"updated": "20211228141446"
"updated": "20220605010033"
},
"Children": [
{
"ID": "20211226121432-ybod3bl",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20211226121432-ybod3bl",
"updated": "20211228141434"
},
"Children": [
{
"ID": "20211226121432-enyxopn",
"Type": "NodeParagraph",
"Properties": {
"id": "20211226121432-enyxopn",
"updated": "20211228141434"
},
"Children": [
{
"Type": "NodeText",
"Data": "備份資料預設存放在 "
},
{
"Type": "NodeCodeSpan",
"Data": "code",
"Children": [
{
"Type": "NodeCodeSpanOpenMarker"
},
{
"Type": "NodeCodeSpanContent",
"Data": "工作空間/backup/"
},
{
"Type": "NodeCodeSpanCloseMarker"
}
]
},
{
"Type": "NodeText",
"Data": " 文件夾下,該位置可修改"
}
]
}
]
},
{
"ID": "20211226121432-0mjndvh",
"Type": "NodeListItem",
@ -648,7 +600,7 @@
},
"Properties": {
"id": "20211226121432-0mjndvh",
"updated": "20211228141437"
"updated": "20220605010033"
},
"Children": [
{
@ -656,68 +608,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20211226121432-8v0c4ao",
"updated": "20211228141437"
"updated": "20220605010033"
},
"Children": [
{
"Type": "NodeText",
"Data": "請勿使用第三方同步碟同步該文件夾,否則可能會造成資料損壞"
}
]
}
]
},
{
"ID": "20211226121432-c653lc8",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20211226121432-c653lc8",
"updated": "20211228141440"
},
"Children": [
{
"ID": "20211226121432-zdxfc6j",
"Type": "NodeParagraph",
"Properties": {
"id": "20211226121432-zdxfc6j",
"updated": "20211228141440"
},
"Children": [
{
"Type": "NodeText",
"Data": "在不改變密碼的情況下,資料是進行增量傳輸的"
}
]
}
]
},
{
"ID": "20211226121432-nhe3knq",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20211226121432-nhe3knq",
"updated": "20211228141443"
},
"Children": [
{
"ID": "20211226121432-r67mbqo",
"Type": "NodeParagraph",
"Properties": {
"id": "20211226121432-r67mbqo",
"updated": "20211228141443"
},
"Children": [
{
"Type": "NodeText",
"Data": "密碼務必牢記,沒有密碼無法恢復資料,且密碼無法清空或找回"
"Data": "請勿同時使用第三方同步盤和思源備份,可能會導致資料損壞"
}
]
}

View file

@ -235,7 +235,7 @@ func RecoverLocalBackup() (err error) {
if syncEnabled {
func() {
time.Sleep(5 * time.Second)
util.PushMsg(Conf.Language(134), 7000)
util.PushMsg(Conf.Language(134), 0)
}()
}
return

View file

@ -229,9 +229,11 @@ func ossDownload(localDirPath, cloudDirPath string, bootOrExit bool) (fetchedFil
return
}
err = ossDownload0(localDirPath, cloudDirPath, "/.siyuan/conf.json", &fetchedFilesCount, &transferSize, bootOrExit)
if nil != err {
return
if "backup" != cloudDirPath {
err = ossDownload0(localDirPath, cloudDirPath, "/.siyuan/conf.json", &fetchedFilesCount, &transferSize, bootOrExit)
if nil != err {
return
}
}
if needPushProgress {
@ -728,7 +730,7 @@ func localUpsertRemoveListOSS(localDirPath string, cloudFileList map[string]*Clo
func cloudUpsertRemoveListOSS(localDirPath string, cloudFileList, localFileList map[string]*CloudIndex, removedSyncList, upsertedSyncList, excludes map[string]bool) (localUpserts, cloudRemoves []string, err error) {
localUpserts, cloudRemoves = []string{}, []string{}
if err = genIncCloudIndex(localDirPath, &localFileList, removedSyncList, upsertedSyncList, excludes); nil != err {
if err = incCloudIndex(localDirPath, &localFileList, removedSyncList, upsertedSyncList, excludes); nil != err {
return
}
@ -763,6 +765,32 @@ func cloudUpsertRemoveListOSS(localDirPath string, cloudFileList, localFileList
}
return nil
})
// syncignore 变更以后 cloud 和 local index 不一致,需要重新补全 local index
for _, upsert := range localUpserts {
info, statErr := os.Stat(upsert)
if nil != statErr {
util.LogErrorf("stat file [%s] failed: %s", upsert, statErr)
err = statErr
return
}
hash, hashErr := util.GetEtag(upsert)
if nil != hashErr {
util.LogErrorf("get file [%s] hash failed: %s", upsert, hashErr)
err = hashErr
return
}
localFileList[filepath.ToSlash(strings.TrimPrefix(upsert, localDirPath))] = &CloudIndex{Hash: hash, Size: info.Size()}
}
data, err := gulu.JSON.MarshalJSON(localFileList)
if nil != err {
util.LogErrorf("marshal sync cloud index failed: %s", err)
return
}
if err = os.WriteFile(filepath.Join(localDirPath, "index.json"), data, 0644); nil != err {
util.LogErrorf("write sync cloud index failed: %s", err)
return
}
return
}

View file

@ -665,8 +665,8 @@ func genFullCloudIndex(localDirPath string, excludes map[string]bool) (err error
return
}
// genCloudIndex 增量生成云端索引文件。
func genIncCloudIndex(localDirPath string, localFileList *map[string]*CloudIndex, removes, upserts, excludes map[string]bool) (err error) {
// incCloudIndex 增量生成云端索引文件。
func incCloudIndex(localDirPath string, localFileList *map[string]*CloudIndex, removes, upserts, excludes map[string]bool) (err error) {
for remove, _ := range removes {
delete(*localFileList, remove)
}
@ -692,16 +692,6 @@ func genIncCloudIndex(localDirPath string, localFileList *map[string]*CloudIndex
}
(*localFileList)[upsert] = &CloudIndex{Hash: hash, Size: info.Size()}
}
data, err := gulu.JSON.MarshalJSON(localFileList)
if nil != err {
util.LogErrorf("marshal sync cloud index failed: %s", err)
return
}
if err = os.WriteFile(filepath.Join(localDirPath, "index.json"), data, 0644); nil != err {
util.LogErrorf("write sync cloud index failed: %s", err)
return
}
return
}