From f51b33769302868327e510f1021a95d7ea85875e Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 12 Jun 2024 12:03:31 +0800 Subject: [PATCH] :art: Display details when exporting .sy.zip and data.zip https://github.com/siyuan-note/siyuan/issues/11696 --- kernel/go.mod | 2 +- kernel/go.sum | 4 ++-- kernel/model/export.go | 20 ++++++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/kernel/go.mod b/kernel/go.mod index 8c01c9e961..eea1b1cddc 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -7,7 +7,7 @@ require ( github.com/88250/clipboard v0.1.5 github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48 github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7 - github.com/88250/gulu v1.2.3-0.20240612021457-b8e8cadd87f3 + github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02 github.com/88250/lute v1.7.7-0.20240611024745-53a7d0cc6568 github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 diff --git a/kernel/go.sum b/kernel/go.sum index 737e1aac6f..3c28b33eab 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -10,8 +10,8 @@ github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7 h1:MafIFwSS0x6A4 github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7/go.mod h1:HrKCCTin3YNDSLBD02K0AOljjV6eNwc3/zyEI+xyV1I= github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceTVVqrYaDlLio2QSKbXMUmAZPbzCwT5eNCw= github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/88250/gulu v1.2.3-0.20240612021457-b8e8cadd87f3 h1:vgVJ0e9hrdEpHOkKcSe45+ht1+O13PWi2ssq8yDVAvQ= -github.com/88250/gulu v1.2.3-0.20240612021457-b8e8cadd87f3/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8= +github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02 h1:3e5+yobj655pTeKOYMbJrnc1mE51ZkbXIxquTYZuYCY= +github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8= github.com/88250/lute v1.7.7-0.20240611024745-53a7d0cc6568 h1:1TwBQATNCmPi4XvEZReYDam8aouz3DZPXUciciTITdg= github.com/88250/lute v1.7.7-0.20240611024745-53a7d0cc6568/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk= github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0= diff --git a/kernel/model/export.go b/kernel/model/export.go index 6f0a91d307..407431d735 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -471,7 +471,12 @@ func exportData(exportFolder string) (zipPath string, err error) { return } - if err = zip.AddDirectory(baseFolderName, exportFolder); nil != err { + zipCallback := func(filename string) { + msg := Conf.language(65) + " " + fmt.Sprintf(Conf.language(70), filename) + util.PushEndlessProgress(msg) + } + + if err = zip.AddDirectory(baseFolderName, exportFolder, zipCallback); nil != err { logging.LogErrorf("create export data zip [%s] failed: %s", exportFolder, err) return } @@ -1462,6 +1467,9 @@ func yfm(docIAL map[string]string) string { } func exportBoxSYZip(boxID string) (zipPath string) { + util.PushEndlessProgress(Conf.Language(65)) + defer util.ClearPushProgress(100) + box := Conf.Box(boxID) if nil == box { logging.LogErrorf("not found box [%s]", boxID) @@ -1607,6 +1615,9 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) ( } copiedAssets.Add(asset) + + msg := Conf.language(65) + " " + fmt.Sprintf(Conf.language(70), asset) + util.PushEndlessProgress(msg) } } @@ -1738,7 +1749,12 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) ( return "" } - if err = zip.AddDirectory(baseFolderName, exportFolder); nil != err { + zipCallback := func(filename string) { + msg := Conf.language(65) + " " + fmt.Sprintf(Conf.language(70), filename) + util.PushEndlessProgress(msg) + } + + if err = zip.AddDirectory(baseFolderName, exportFolder, zipCallback); nil != err { logging.LogErrorf("create export .sy.zip [%s] failed: %s", exportFolder, err) return "" }