mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
🎨 改进导出 Data 压缩包过程 Fix https://github.com/siyuan-note/siyuan/issues/6961
This commit is contained in:
parent
7688733364
commit
7e214231d9
2 changed files with 22 additions and 9 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue