mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 15:58:49 +01:00
🎨 Data repo no longer automatically resets after corrupted https://github.com/siyuan-note/siyuan/issues/10580
This commit is contained in:
parent
95764092ec
commit
e58520b6ce
8 changed files with 25 additions and 54 deletions
|
|
@ -1307,7 +1307,7 @@
|
|||
"102": "Processing completed",
|
||||
"103": "The update installation package has been automatically downloaded in the background. When exiting, you will be asked whether to install the new version",
|
||||
"104": "The update installation package failed to download, please check the network connection",
|
||||
"105": "Corrupted data repo have been automatically reset",
|
||||
"105": "TODO",
|
||||
"106": "Maximum length is limited to 512 characters",
|
||||
"107": "Moved document [%s]",
|
||||
"108": "Data sync found conflicts, you can view the generated conflict content in [Data History]",
|
||||
|
|
|
|||
|
|
@ -1307,7 +1307,7 @@
|
|||
"102": "Procesamiento completado",
|
||||
"103": "El paquete de instalación de la actualización se ha descargado automáticamente en segundo plano. Al salir, se le preguntará si desea instalar la nueva versión",
|
||||
"104": "El paquete de instalación de la actualización no se pudo descargar, verifique la conexión de red",
|
||||
"105": "El repositorio de datos corruptos se ha restablecido automáticamente",
|
||||
"105": "TODO",
|
||||
"106": "La longitud máxima está limitada a 512 caracteres",
|
||||
"107": "Documento movido [%s]",
|
||||
"108": "La sincronizaci\u00f3n de datos encontr\u00f3 en conflictos, puede ver el contenido del conflicto generado en [Historial de datos]",
|
||||
|
|
|
|||
|
|
@ -1307,7 +1307,7 @@
|
|||
"102": "Traitement terminé",
|
||||
"103": "Le package d'installation de la mise à jour a été automatiquement téléchargé en arrière-plan. En quittant, il vous sera demandé si vous souhaitez installer la nouvelle version",
|
||||
"104": "Le package d'installation de la mise à jour n'a pas pu être téléchargé, veuillez vérifier la connexion réseau",
|
||||
"105": "Le référentiel de données corrompu a été automatiquement réinitialisé",
|
||||
"105": "TODO",
|
||||
"106": "La longueur maximale est limitée à 512 caractères",
|
||||
"107": "Document déplacé [%s]",
|
||||
"108": "La synchronisation des données a trouvé des conflits, vous pouvez afficher le contenu du conflit généré dans [Historique des données]",
|
||||
|
|
|
|||
|
|
@ -1307,7 +1307,7 @@
|
|||
"102": "處理完畢",
|
||||
"103": "已經在後台開始自動下載更新安裝檔,退出時將詢問是否安裝新版本",
|
||||
"104": "更新安裝檔下載失敗,請檢查網絡連接",
|
||||
"105": "已經自動重置損壞的資料倉庫",
|
||||
"105": "TODO",
|
||||
"106": "最大長度限制為 512 字元",
|
||||
"107": "已經移動文檔 [%s]",
|
||||
"108": "資料同步發現衝突,可在 [資料歷史] 中查看生成的衝突內容",
|
||||
|
|
|
|||
|
|
@ -1307,7 +1307,7 @@
|
|||
"102": "处理完毕",
|
||||
"103": "已经在后台开始自动下载更新安装包,退出时将询问是否安装新版本",
|
||||
"104": "更新安装包下载失败,请检查网络连接",
|
||||
"105": "已经自动重置损坏的数据仓库",
|
||||
"105": "TODO",
|
||||
"106": "最大长度限制为 512 字符",
|
||||
"107": "已经移动文档 [%s]",
|
||||
"108": "数据同步发现冲突,可在 [数据历史] 中查看生成的冲突内容",
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ require (
|
|||
github.com/goccy/go-json v0.10.2
|
||||
github.com/gofrs/flock v0.8.1
|
||||
github.com/gorilla/websocket v1.5.1
|
||||
github.com/imroc/req/v3 v3.43.0
|
||||
github.com/imroc/req/v3 v3.43.1
|
||||
github.com/jinzhu/copier v0.4.0
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/klippa-app/go-pdfium v1.11.0
|
||||
|
|
@ -55,7 +55,7 @@ require (
|
|||
github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4
|
||||
github.com/siyuan-note/eventbus v0.0.0-20240124091459-8e1b37a55255
|
||||
github.com/siyuan-note/filelock v0.0.0-20240128091141-94d7bb3e0772
|
||||
github.com/siyuan-note/httpclient v0.0.0-20240306121400-b3af777a1f1b
|
||||
github.com/siyuan-note/httpclient v0.0.0-20240312073515-af29be1cfb4e
|
||||
github.com/siyuan-note/logging v0.0.0-20231208035918-61f884c854f0
|
||||
github.com/siyuan-note/riff v0.0.0-20240305012846-494c7fb46c45
|
||||
github.com/spf13/cast v1.6.0
|
||||
|
|
|
|||
|
|
@ -199,6 +199,8 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
|
|||
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
|
||||
github.com/imroc/req/v3 v3.43.0 h1:TZDLMcuXEUFOvoyjKI2vMeimhq/OWnxvRJDPfEVCEhk=
|
||||
github.com/imroc/req/v3 v3.43.0/go.mod h1:SQIz5iYop16MJxbo8ib+4LnostGCok8NQf8ToyQc2xA=
|
||||
github.com/imroc/req/v3 v3.43.1 h1:tsWAhvxik4egtHAvMlxcjaWJtHlJL8EpBqJMOm5rmyQ=
|
||||
github.com/imroc/req/v3 v3.43.1/go.mod h1:SQIz5iYop16MJxbo8ib+4LnostGCok8NQf8ToyQc2xA=
|
||||
github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
|
||||
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 h1:iCHtR9CQyktQ5+f3dMVZfwD2KWJUgm7M0gdL9NGr8KA=
|
||||
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
|
||||
|
|
@ -361,6 +363,8 @@ github.com/siyuan-note/filelock v0.0.0-20240128091141-94d7bb3e0772 h1:ceX49LJmN8
|
|||
github.com/siyuan-note/filelock v0.0.0-20240128091141-94d7bb3e0772/go.mod h1:CYJQjSyKYLhEJJC+5I+R4uNcpyW0X2CaUYwMVbkelDk=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20240306121400-b3af777a1f1b h1:t8xkj25nNOQXsS6grX2kpFcNeOydjrT250ahdzWosos=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20240306121400-b3af777a1f1b/go.mod h1:mgg/IhCzGQ5h2k6QTTn0kFSR7cCMN/Xb313eTpAedic=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20240312073515-af29be1cfb4e h1:2DeWT+8qGw2mqF03Z7R9gwPJ7WTUqDrQSv5Yo/NxxYA=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20240312073515-af29be1cfb4e/go.mod h1:v/O6xcc3HomxJR1dLwENGan9RB08WqSPv4kxyzaTSUI=
|
||||
github.com/siyuan-note/logging v0.0.0-20231208035918-61f884c854f0 h1:+XjUr9UMXsczdO2bGA72p/k9wa2ShPb8ybi7CDBJ7HQ=
|
||||
github.com/siyuan-note/logging v0.0.0-20231208035918-61f884c854f0/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=
|
||||
github.com/siyuan-note/riff v0.0.0-20240305012846-494c7fb46c45 h1:/ORGs2Llh98lXSiR3mt/8vZKrAOQAIB4LQkh1aslaow=
|
||||
|
|
|
|||
|
|
@ -1024,12 +1024,6 @@ func syncRepoDownload() (err error) {
|
|||
|
||||
syncContext := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
|
||||
mergeResult, trafficStat, err := repo.SyncDownload(syncContext)
|
||||
if errors.Is(err, dejavu.ErrRepoFatal) {
|
||||
// 重置仓库并再次尝试同步
|
||||
if _, resetErr := resetRepository(repo); nil == resetErr {
|
||||
mergeResult, trafficStat, err = repo.SyncDownload(syncContext)
|
||||
}
|
||||
}
|
||||
elapsed := time.Since(start)
|
||||
if nil != err {
|
||||
planSyncAfter(fixSyncInterval)
|
||||
|
|
@ -1094,12 +1088,6 @@ func syncRepoUpload() (err error) {
|
|||
|
||||
syncContext := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
|
||||
trafficStat, err := repo.SyncUpload(syncContext)
|
||||
if errors.Is(err, dejavu.ErrRepoFatal) {
|
||||
// 重置仓库并再次尝试同步
|
||||
if _, resetErr := resetRepository(repo); nil == resetErr {
|
||||
trafficStat, err = repo.SyncUpload(syncContext)
|
||||
}
|
||||
}
|
||||
elapsed := time.Since(start)
|
||||
if nil != err {
|
||||
planSyncAfter(fixSyncInterval)
|
||||
|
|
@ -1172,10 +1160,18 @@ func bootSyncRepo() (err error) {
|
|||
syncContext := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
|
||||
fetchedFiles, err := repo.GetSyncCloudFiles(syncContext)
|
||||
if errors.Is(err, dejavu.ErrRepoFatal) {
|
||||
// 重置仓库并再次尝试同步
|
||||
if _, resetErr := resetRepository(repo); nil == resetErr {
|
||||
fetchedFiles, err = repo.GetSyncCloudFiles(syncContext)
|
||||
}
|
||||
autoSyncErrCount++
|
||||
planSyncAfter(fixSyncInterval)
|
||||
|
||||
logging.LogErrorf("data repo is corrupted: %s", err)
|
||||
msg := fmt.Sprintf(Conf.Language(80), formatRepoErrorMsg(err))
|
||||
Conf.Sync.Stat = msg
|
||||
Conf.Save()
|
||||
util.PushStatusBar(msg)
|
||||
util.PushErrMsg(msg, 0)
|
||||
BootSyncSucc = 1
|
||||
isBootSyncing.Store(false)
|
||||
return
|
||||
}
|
||||
|
||||
syncingFiles = sync.Map{}
|
||||
|
|
@ -1266,12 +1262,6 @@ func syncRepo(exit, byHand bool) (dataChanged bool, err error) {
|
|||
|
||||
syncContext := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
|
||||
mergeResult, trafficStat, err := repo.Sync(syncContext)
|
||||
if errors.Is(err, dejavu.ErrRepoFatal) {
|
||||
// 重置仓库并再次尝试同步
|
||||
if _, resetErr := resetRepository(repo); nil == resetErr {
|
||||
mergeResult, trafficStat, err = repo.Sync(syncContext)
|
||||
}
|
||||
}
|
||||
elapsed := time.Since(start)
|
||||
if nil != err {
|
||||
autoSyncErrCount++
|
||||
|
|
@ -1529,12 +1519,8 @@ func indexRepoBeforeCloudSync(repo *dejavu.Repo) (beforeIndex, afterIndex *entit
|
|||
eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar,
|
||||
})
|
||||
if errors.Is(err, dejavu.ErrNotFoundObject) {
|
||||
var resetErr error
|
||||
afterIndex, resetErr = resetRepository(repo)
|
||||
if nil != resetErr {
|
||||
return
|
||||
}
|
||||
err = nil
|
||||
logging.LogErrorf("data repo is corrupted: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
if nil != err {
|
||||
|
|
@ -1579,25 +1565,6 @@ func indexRepoBeforeCloudSync(repo *dejavu.Repo) (beforeIndex, afterIndex *entit
|
|||
return
|
||||
}
|
||||
|
||||
func resetRepository(repo *dejavu.Repo) (index *entity.Index, err error) {
|
||||
logging.LogWarnf("data repo is corrupted, try to reset it")
|
||||
err = os.RemoveAll(filepath.Join(repo.Path))
|
||||
if nil != err {
|
||||
logging.LogErrorf("remove data repo failed: %s", err)
|
||||
return
|
||||
}
|
||||
index, err = repo.Index("[Sync] Cloud sync", map[string]interface{}{
|
||||
eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar,
|
||||
})
|
||||
logging.LogWarnf("data repo has been reset")
|
||||
|
||||
go func() {
|
||||
time.Sleep(5 * time.Second)
|
||||
util.PushMsg(Conf.Language(105), 5000)
|
||||
}()
|
||||
return
|
||||
}
|
||||
|
||||
func newRepository() (ret *dejavu.Repo, err error) {
|
||||
cloudConf, err := buildCloudConf()
|
||||
if nil != err {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue