import/export: use background thread

This commit is contained in:
mappu 2025-04-18 12:13:56 +12:00
parent 0ad7c03db0
commit 1725de6ace

View File

@ -7,6 +7,7 @@ import (
"strings" "strings"
qt "github.com/mappu/miqt/qt6" qt "github.com/mappu/miqt/qt6"
"github.com/mappu/miqt/qt6/mainthread"
bolt "go.etcd.io/bbolt" bolt "go.etcd.io/bbolt"
) )
@ -186,13 +187,17 @@ func (this *MainWindow) onactionExport_database_as_zip_triggered() {
return return
} }
go func() {
err := Bolt_ExportDatabaseToZip(dbPath, zipPath) err := Bolt_ExportDatabaseToZip(dbPath, zipPath)
mainthread.Start(func() {
if err != nil { if err != nil {
this.alert(fmt.Sprintf("Error exporting database as zip: %s", err.Error())) this.alert(fmt.Sprintf("Error exporting database as zip: %s", err.Error()))
return return
} }
this.alert("Exported as zip successfully.") this.alert("Exported as zip successfully.")
})
}()
} }
func (this *MainWindow) onactionCreate_database_from_zip_triggered() { func (this *MainWindow) onactionCreate_database_from_zip_triggered() {
@ -214,13 +219,17 @@ func (this *MainWindow) onactionCreate_database_from_zip_triggered() {
return return
} }
go func() {
err := Bolt_ImportZipToDatabase(dbPath, zipPath) err := Bolt_ImportZipToDatabase(dbPath, zipPath)
mainthread.Start(func() {
if err != nil { if err != nil {
this.alert(fmt.Sprintf("Error importing database from zip %q: %s", zipPath, err.Error())) this.alert(fmt.Sprintf("Error importing database from zip %q: %s", zipPath, err.Error()))
return return
} }
this.alert("Imported zip to database successfully.") this.alert("Imported zip to database successfully.")
})
}()
} }
func (this *MainWindow) refreshBucketTree(itm *qt.QTreeWidgetItem) { func (this *MainWindow) refreshBucketTree(itm *qt.QTreeWidgetItem) {