This commit is contained in:
Liang Ding 2022-06-14 23:29:06 +08:00
parent e7a45d4026
commit f49127edf5
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 19 additions and 11 deletions

View file

@ -34,6 +34,7 @@ import (
"github.com/dustin/go-humanize"
"github.com/siyuan-note/encryption"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -141,9 +142,11 @@ func RecoverLocalBackup() (err error) {
return errors.New(Conf.Language(11))
}
data := util.AESDecrypt(Conf.E2EEPasswd)
data, _ = hex.DecodeString(string(data))
passwd := string(data)
writingDataLock.Lock()
defer writingDataLock.Unlock()
filesys.ReleaseAllFileLocks()
sql.WaitForWritingDatabase()
CloseWatchAssets()
defer WatchAssets()
@ -153,17 +156,17 @@ func RecoverLocalBackup() (err error) {
Conf.Sync.Enabled = false
Conf.Save()
filesys.ReleaseAllFileLocks()
util.PushEndlessProgress(Conf.Language(63))
util.LogInfof("starting recovery...")
start := time.Now()
data := util.AESDecrypt(Conf.E2EEPasswd)
data, _ = hex.DecodeString(string(data))
passwd := string(data)
decryptedDataDir, err := decryptDataDir(passwd)
if nil != err {
util.ClearPushProgress(100)
return
}
newDataDir := filepath.Join(util.WorkspaceDir, "data.new")
os.RemoveAll(newDataDir)
if err = os.MkdirAll(newDataDir, 0755); nil != err {

View file

@ -28,6 +28,7 @@ import (
"github.com/siyuan-note/dejavu/entity"
"github.com/siyuan-note/encryption"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -131,10 +132,13 @@ func CheckoutRepo(id string) (err error) {
return
}
filesys.ReleaseAllFileLocks()
util.PushEndlessProgress(Conf.Language(63))
writingDataLock.Lock()
defer writingDataLock.Unlock()
filesys.ReleaseAllFileLocks()
sql.WaitForWritingDatabase()
CloseWatchAssets()
defer WatchAssets()