diff --git a/src/app/common/themes/themes.less b/src/app/common/themes/themes.less index fcb94aae..a5bab673 100644 --- a/src/app/common/themes/themes.less +++ b/src/app/common/themes/themes.less @@ -1,7 +1,7 @@ @base-color: #eceeec; @base-background: rgba(21, 23, 21, 1); @base-background-transparent: rgba(21, 23, 21, 0.7); -@base-background-dev: rgba(57, 0, 78, 0.7); +@base-background-dev: rgba(21, 23, 48, 0.7); @base-border: rgba(241, 246, 243, 0.08); @background-session: rgba(13, 13, 13, 0.85); @background-session-components: rgba(48, 49, 48, 0.6); diff --git a/wavesrv/pkg/sstore/migrate.go b/wavesrv/pkg/sstore/migrate.go index afd8bfd7..82d96393 100644 --- a/wavesrv/pkg/sstore/migrate.go +++ b/wavesrv/pkg/sstore/migrate.go @@ -4,8 +4,10 @@ package sstore import ( + "errors" "fmt" "io" + "io/fs" "log" "os" "strconv" @@ -40,11 +42,14 @@ func MakeMigrate() (*migrate.Migrate, error) { return m, nil } -func copyFile(srcFile string, dstFile string) error { +func copyFile(srcFile string, dstFile string, notFoundOk bool) error { if srcFile == dstFile { return fmt.Errorf("cannot copy %s to itself", srcFile) } srcFd, err := os.Open(srcFile) + if notFoundOk && err != nil && errors.Is(err, fs.ErrNotExist) { + return nil + } if err != nil { return fmt.Errorf("cannot open %s: %v", err) } @@ -100,10 +105,16 @@ func MigrateUp(targetVersion uint) error { } log.Printf("[db] migrating from %d to %d\n", curVersion, targetVersion) log.Printf("[db] backing up database %s to %s\n", DBFileName, DBFileNameBackup) - err = copyFile(GetDBName(), GetDBBackupName()) + os.Remove(GetDBBackupName()) // don't report error + os.Remove(GetDBWALBackupName()) // don't report error + err = copyFile(GetDBName(), GetDBBackupName(), false) if err != nil { return fmt.Errorf("error creating database backup: %v", err) } + err = copyFile(GetDBWALName(), GetDBWALBackupName(), true) + if err != nil { + return fmt.Errorf("error creating database(wal) backup: %v", err) + } for newVersion := curVersion + 1; newVersion <= targetVersion; newVersion++ { err = MigrateUpStep(m, newVersion) if err != nil { diff --git a/wavesrv/pkg/sstore/sstore.go b/wavesrv/pkg/sstore/sstore.go index 3c3c4173..34a2ff04 100644 --- a/wavesrv/pkg/sstore/sstore.go +++ b/wavesrv/pkg/sstore/sstore.go @@ -34,7 +34,9 @@ import ( const LineNoHeight = -1 const DBFileName = "waveterm.db" +const DBWALFileName = "waveterm.db-wal" const DBFileNameBackup = "backup.waveterm.db" +const DBWALFileNameBackup = "backup.waveterm.db-wal" const MaxWebShareLineCount = 50 const MaxWebShareScreenCount = 3 const MaxLineStateSize = 4 * 1024 // 4k for now, can raise if needed @@ -149,11 +151,21 @@ func GetDBName() string { return path.Join(scHome, DBFileName) } +func GetDBWALName() string { + scHome := scbase.GetWaveHomeDir() + return path.Join(scHome, DBWALFileName) +} + func GetDBBackupName() string { scHome := scbase.GetWaveHomeDir() return path.Join(scHome, DBFileNameBackup) } +func GetDBWALBackupName() string { + scHome := scbase.GetWaveHomeDir() + return path.Join(scHome, DBWALFileNameBackup) +} + func IsValidConnectMode(mode string) bool { return mode == ConnectModeStartup || mode == ConnectModeAuto || mode == ConnectModeManual }