From 91e5ddd04952270269186f3b745bf02e8296e18d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 5 Jun 2022 01:34:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:memo:=20=E6=9B=B4=E6=96=B0=E4=BA=91?= =?UTF-8?q?=E7=AB=AF=E6=95=B0=E6=8D=AE=E5=A4=87=E4=BB=BD=E6=B3=A8=E6=84=8F?= =?UTF-8?q?=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20210721112211-fwc1x43.sy | 110 ++-------------- .../20201002090451-hb9j8ai.sy | 117 ++---------------- .../20211226121413-nznc7x0.sy | 114 +---------------- 3 files changed, 19 insertions(+), 322 deletions(-) diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-v9awwp0/20210721112211-fwc1x43.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-v9awwp0/20210721112211-fwc1x43.sy index fa59d6315..a6c1ec151 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-v9awwp0/20210721112211-fwc1x43.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-v9awwp0/20210721112211-fwc1x43.sy @@ -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" } ] } diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-m0ztypq/20201002090451-hb9j8ai.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-m0ztypq/20201002090451-hb9j8ai.sy index f43354783..d4c824a3e 100644 --- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-m0ztypq/20201002090451-hb9j8ai.sy +++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-m0ztypq/20201002090451-hb9j8ai.sy @@ -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": [ { diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121232-23s79xr/20211226121413-nznc7x0.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121232-23s79xr/20211226121413-nznc7x0.sy index 328d65d7c..689040f26 100644 --- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121232-23s79xr/20211226121413-nznc7x0.sy +++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121232-23s79xr/20211226121413-nznc7x0.sy @@ -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": "請勿同時使用第三方同步盤和思源備份,可能會導致資料損壞" } ] } From a1d2ab5ff9be5ea341c9306438d23b755690ef54 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 5 Jun 2022 01:34:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E4=BA=91?= =?UTF-8?q?=E7=AB=AF=E5=90=8C=E6=AD=A5=E4=B8=8A=E4=BC=A0=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=8D=A0=E7=94=A8=20https://github.com/siyuan-note/siyuan/issu?= =?UTF-8?q?es/5093?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/osssync.go | 28 +++++++++++++++++++++++++++- kernel/model/sync.go | 14 ++------------ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/kernel/model/osssync.go b/kernel/model/osssync.go index baa3adf1c..972d1d4d6 100644 --- a/kernel/model/osssync.go +++ b/kernel/model/osssync.go @@ -728,7 +728,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 +763,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 } diff --git a/kernel/model/sync.go b/kernel/model/sync.go index ef40a9b8d..1c2842a25 100644 --- a/kernel/model/sync.go +++ b/kernel/model/sync.go @@ -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 } From 8c394288633fb58ca0a3978728ab2f48a029d79b Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 5 Jun 2022 01:54:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?:bug:=20=E4=BA=91=E7=AB=AF=E5=A4=87?= =?UTF-8?q?=E4=BB=BD=E4=B8=8B=E8=BD=BD=E6=81=A2=E5=A4=8D=E6=8A=A5=E9=94=99?= =?UTF-8?q?=20Fix=20https://github.com/siyuan-note/siyuan/issues/5101?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/backup.go | 2 +- kernel/model/osssync.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/model/backup.go b/kernel/model/backup.go index fc41a6253..fae75c5cb 100644 --- a/kernel/model/backup.go +++ b/kernel/model/backup.go @@ -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 diff --git a/kernel/model/osssync.go b/kernel/model/osssync.go index 972d1d4d6..ed388eca0 100644 --- a/kernel/model/osssync.go +++ b/kernel/model/osssync.go @@ -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 {