diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 8b853e145..6f2eb5c1f 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -1540,7 +1540,7 @@ "239": "Related operations are being processed, please try again later", "240": "The current drag-and-drop heading is located in the container block and the drag-and-drop operation cannot be performed", "241": "Drag to its subheading is not supported", - "242": "TODO", + "242": "Currently available space is [%s], at least [%s] is required to perform this operation", "243": "Only list the first [%d] tags (including subtags), if you need to adjust, please modify [Settings - Doc Tree - Maximum number to list]", "244": "Data indexing was not completed after the last use. Please execute [Doc Tree - Rebuild Index]. Please exit the program completely before shutting down the computer", "245": "Data indexing was not completed after the last use. Please execute [Doc Tree - Rebuild Index]. Please use [Exit Application] in the right column panel to exit normally", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index f9c8dcaef..06c61d652 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1540,7 +1540,7 @@ "239": "Las operaciones relacionadas se están procesando, inténtalo de nuevo más tarde", "240": "El encabezado actual de arrastrar y soltar está ubicado en el bloque contenedor y la operación de arrastrar y soltar no se puede realizar", "241": "No se admite arrastrar a su subtítulo", - "242": "TODO", + "242": "Espacio disponible actualmente [%s], se requiere al menos [%s] para realizar esta operación", "243": "Enumere solo las primeras [%d] etiquetas (incluidas las subetiquetas), modifique [Configuración - Árbol de documentos - Número máximo a listar]", "244": "La indexación de datos no se ha completado desde el último uso. Ejecute [Árbol de documentos - Reconstruir índice] una vez. En el futuro, salga completamente del programa antes de apagar la computadora.", "245": "La indexación de datos no se ha completado desde el último uso. Ejecute [Árbol de documentos - Reconstruir índice] una vez. Utilice [Salir de la aplicación] en el panel de la columna derecha para salir normalmente", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 4a9cfabb9..e45a9d7f3 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -1540,7 +1540,7 @@ "239": "Les opérations associées sont en cours de traitement, veuillez réessayer plus tard", "240": "L'en-tête du glisser-déposer actuel se trouve dans le bloc conteneur et l'opération de glisser-déposer ne peut pas être effectuée", "241": "Le glisser vers son sous-titre n'est pas pris en charge", - "242": "TODO", + "242": "Espace actuellement disponible [%s], au moins [%s] est requis pour effectuer cette opération", "243": "Répertorier uniquement les [%d] premières balises (y compris les sous-balises). veuillez modifier [Paramètres - Arbre des documents - Nombre maximum de documents à lister].", "244": "L'indexation des données n'a pas été terminée depuis la dernière utilisation. Veuillez exécuter [Arborescence des documents - Reconstruire l'index] une fois. À l'avenir, veuillez quitter complètement le programme avant d'éteindre l'ordinateur.", "245": "L'indexation des données n'a pas été terminée depuis la dernière utilisation. Veuillez exécuter [Arborescence des documents - Reconstruire l'index] une fois. Veuillez utiliser [Quitter l'application] dans le panneau de la colonne de droite pour quitter normalement", diff --git a/app/appearance/langs/ja_JP.json b/app/appearance/langs/ja_JP.json index ca0fa4aba..1a7c4346d 100644 --- a/app/appearance/langs/ja_JP.json +++ b/app/appearance/langs/ja_JP.json @@ -1540,7 +1540,7 @@ "239": "関連する操作が処理中です。後でまた試してください", "240": "コンテナブロック内の見出しは移動できません", "241": "小見出しへのドラッグはサポートされていません", - "242": "TODO", + "242": "現在利用可能なスペース [%s]、この操作を実行するには少なくとも [%s] が必要です", "243": "最初の [%d] 個のタグ (サブタグを含む) のみを表示します。調整が必要な場合は [設定] - [ドキュメントツリー] - [リストする最大数] を変更してください", "244": "前回の使用以降、データのインデックス作成が完了していません。[ドキュメント ツリー - インデックスの再構築]を一度実行してください。今後は、コンピューターをシャットダウンする前にプログラムを完全に終了してください。", "245": "前回の使用以降、データのインデックス作成が完了していません。[ドキュメント ツリー - インデックスの再構築]を一度実行してください。正常に終了するには、右列パネルの[アプリケーションの終了]を使用してください。", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index c87e52021..33074864e 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1540,7 +1540,7 @@ "239": "相關操作正在處理中,請稍後再試", "240": "目前拖曳標題位於容器區塊中,無法進行拖曳操作", "241": "不支持拖曳為自己的子標題", - "242": "TODO", + "242": "目前可用空間 [%s],至少需要 [%s] 才能執行該動作", "243": "僅列出前 [%d] 個標籤(含子標籤),如需調整請修改 [設置 - 文檔樹 - 最大列出數量]", "244": "上次使用後未完成資料索引,請執行一次 [文檔樹 - 重建索引]。以後請完整退出程式後再關閉電腦", "245": "上次使用後未完成資料索引,請執行一次 [文檔樹 - 重建索引]。以後請使用右側欄面板中的 [退出應用] 進行正常退出", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 8444223d1..1f523e809 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1540,7 +1540,7 @@ "239": "相关操作正在处理中,请稍后再试", "240": "当前拖拽标题位于容器块中,无法进行拖拽操作", "241": "不支持拖拽为自己的子标题", - "242": "TODO", + "242": "当前可用空间 [%s],至少需要 [%s] 才能执行该操作", "243": "仅列出前 [%d] 个标签(含子标签),如需调整请修改 [设置 - 文档树 - 最大列出数量]", "244": "上次使用后未完成数据索引,请执行一次 [文档树 - 重建索引]。以后请完整退出程序后再关闭电脑", "245": "上次使用后未完成数据索引,请执行一次 [文档树 - 重建索引]。以后请使用右侧栏面板中的 [退出应用] 进行正常退出", diff --git a/kernel/model/export.go b/kernel/model/export.go index 67be1bfa8..ae7d9c792 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -33,6 +33,7 @@ import ( "time" "unicode/utf8" + "github.com/88250/go-humanize" "github.com/88250/gulu" "github.com/88250/lute/ast" "github.com/88250/lute/editor" @@ -413,6 +414,30 @@ func ExportDataInFolder(exportFolder string) (name string, err error) { util.PushEndlessProgress(Conf.Language(65)) defer util.ClearPushProgress(100) + data := filepath.Join(util.WorkspaceDir, "data") + if util.ContainerStd == util.Container { + // 桌面端检查磁盘可用空间 + + dataSize, sizeErr := util.SizeOfDirectory(data) + if sizeErr != nil { + logging.LogErrorf("get size of data dir [%s] failed: %s", data, sizeErr) + err = sizeErr + return + } + + _, _, tempExportFree := util.GetDiskUsage(util.TempDir) + if int64(tempExportFree) < dataSize*2 { // 压缩 zip 文件时需要 data 的两倍空间 + err = errors.New(fmt.Sprintf(Conf.Language(242), humanize.BytesCustomCeil(tempExportFree, 2), humanize.BytesCustomCeil(uint64(dataSize)*2, 2))) + return + } + + _, _, targetExportFree := util.GetDiskUsage(exportFolder) + if int64(targetExportFree) < dataSize { // 复制 zip 最多需要 data 一样的空间 + err = errors.New(fmt.Sprintf(Conf.Language(242), humanize.BytesCustomCeil(targetExportFree, 2), humanize.BytesCustomCeil(uint64(dataSize), 2))) + return + } + } + zipPath, err := ExportData() if err != nil { return @@ -424,6 +449,9 @@ func ExportDataInFolder(exportFolder string) (name string, err error) { return } + util.PushEndlessProgress(Conf.Language(65)) + defer util.ClearPushProgress(100) + targetZipPath := filepath.Join(exportFolder, name) zipAbsPath := filepath.Join(util.TempDir, "export", name) err = filelock.Copy(zipAbsPath, targetZipPath) diff --git a/kernel/util/disk.go b/kernel/util/disk.go index 39882ed67..19ad50f7f 100644 --- a/kernel/util/disk.go +++ b/kernel/util/disk.go @@ -33,3 +33,12 @@ func NeedWarnDiskUsage(dataSize int64) bool { logging.LogInfof("disk usage [total=%s, used=%s, free=%s]", humanize.BytesCustomCeil(usage.Total, 2), humanize.BytesCustomCeil(usage.Used, 2), humanize.BytesCustomCeil(usage.Free, 2)) return usage.Free < uint64(dataSize*2) } + +func GetDiskUsage(p string) (total, used, free uint64) { + usage, err := disk.Usage(p) + if err != nil { + logging.LogErrorf("get disk usage failed: %s", err) + return + } + return usage.Total, usage.Used, usage.Free +}