🎨 改进导出 Data 压缩包过程 Fix https://github.com/siyuan-note/siyuan/issues/6961

This commit is contained in:
Liang Ding 2022-12-31 16:30:24 +08:00
parent 7688733364
commit 7e214231d9
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 22 additions and 9 deletions

View file

@ -125,25 +125,30 @@ func ExportDataInFolder(exportFolder string) (name string, err error) {
util.PushEndlessProgress(Conf.Language(65))
defer util.ClearPushProgress(100)
WaitForWritingFiles()
exportFolder = filepath.Join(exportFolder, util.CurrentTimeSecondsStr())
zipPath, err := exportData(exportFolder)
zipPath, err := ExportData()
if nil != err {
return
}
name = filepath.Base(zipPath)
targetZipPath := filepath.Join(exportFolder, name)
zipAbsPath := filepath.Join(util.TempDir, "export", name)
err = filelock.RoboCopy(zipAbsPath, targetZipPath)
if nil != err {
logging.LogErrorf("copy export zip from [%s] to [%s] failed: %s", zipAbsPath, targetZipPath, err)
return
}
if removeErr := os.Remove(zipAbsPath); nil != removeErr {
logging.LogErrorf("remove export zip failed: %s", removeErr)
}
return
}
func ExportData() (zipPath string) {
func ExportData() (zipPath string, err error) {
util.PushEndlessProgress(Conf.Language(65))
defer util.ClearPushProgress(100)
WaitForWritingFiles()
exportFolder := filepath.Join(util.TempDir, "export", util.CurrentTimeSecondsStr())
zipPath, err := exportData(exportFolder)
zipPath, err = exportData(exportFolder)
if nil != err {
return
}
@ -152,6 +157,8 @@ func ExportData() (zipPath string) {
}
func exportData(exportFolder string) (zipPath string, err error) {
WaitForWritingFiles()
baseFolderName := "data-" + util.CurrentTimeSecondsStr()
if err = os.MkdirAll(exportFolder, 0755); nil != err {
logging.LogErrorf("create export temp folder failed: %s", err)