Some cosmetic fixes from #4106 (#4236)

This commit is contained in:
its-josh4 2023-10-22 14:20:41 -07:00 committed by GitHub
parent 24984da16e
commit b99d16b712
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 27 deletions

View file

@ -1,10 +1,11 @@
//go:build !windows && !darwin
// +build !windows,!darwin
//go:build (!windows && !darwin) || !cgo
package desktop
func startSystray(shutdownHandler ShutdownHandler, favicon FaviconProvider) {
// The systray is not available on linux because the required libraries (libappindicator3 and gtk+3.0)
// The systray is not available on Linux because the required libraries (libappindicator3 and gtk+3.0)
// are not able to be statically compiled. Technically, the systray works perfectly fine when dynamically
// linked, but we cannot distribute it for compatibility reasons.
// Additionally, the systray package requires CGo so the dependency cannot be used if building with
// CGo disabled.
}

View file

@ -1,5 +1,4 @@
//go:build windows || darwin
// +build windows darwin
//go:build (windows || darwin) && cgo
package desktop
@ -7,15 +6,15 @@ import (
"strings"
"github.com/kermieisinthehouse/systray"
"github.com/stashapp/stash/internal/manager/config"
"github.com/stashapp/stash/pkg/logger"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"github.com/stashapp/stash/internal/manager/config"
"github.com/stashapp/stash/pkg/logger"
)
// MUST be run on the main goroutine or will have no effect on macOS
func startSystray(shutdownHandler ShutdownHandler, faviconProvider FaviconProvider) {
// Shows a small notification to inform that Stash will no longer show a terminal window,
// and instead will be available in the tray. Will only show the first time a pre-desktop integration
// system is started from a non-terminal method, e.g. double-clicking an icon.

View file

@ -145,7 +145,7 @@ func (db *Database) Open(dbPath string) error {
if databaseSchemaVersion == 0 {
// new database, just run the migrations
if err := db.RunMigrations(); err != nil {
return fmt.Errorf("error running initial schema migrations: %v", err)
return fmt.Errorf("error running initial schema migrations: %w", err)
}
} else {
if databaseSchemaVersion > appSchemaVersion {
@ -241,12 +241,12 @@ func (db *Database) Remove() error {
err := db.Close()
if err != nil {
return errors.New("Error closing database: " + err.Error())
return fmt.Errorf("error closing database: %w", err)
}
err = os.Remove(databasePath)
if err != nil {
return errors.New("Error removing database: " + err.Error())
return fmt.Errorf("error removing database: %w", err)
}
// remove the -shm, -wal files ( if they exist )
@ -255,7 +255,7 @@ func (db *Database) Remove() error {
if exists, _ := fsutil.FileExists(wf); exists {
err = os.Remove(wf)
if err != nil {
return errors.New("Error removing database: " + err.Error())
return fmt.Errorf("error removing database: %w", err)
}
}
}
@ -278,21 +278,20 @@ func (db *Database) Reset() error {
// Backup the database. If db is nil, then uses the existing database
// connection.
func (db *Database) Backup(backupPath string) error {
func (db *Database) Backup(backupPath string) (err error) {
thisDB := db.db
if thisDB == nil {
var err error
thisDB, err = sqlx.Connect(sqlite3Driver, "file:"+db.dbPath+"?_fk=true")
if err != nil {
return fmt.Errorf("open database %s failed: %v", db.dbPath, err)
return fmt.Errorf("open database %s failed: %w", db.dbPath, err)
}
defer thisDB.Close()
}
logger.Infof("Backing up database into: %s", backupPath)
_, err := thisDB.Exec(`VACUUM INTO "` + backupPath + `"`)
_, err = thisDB.Exec(`VACUUM INTO "` + backupPath + `"`)
if err != nil {
return fmt.Errorf("vacuum failed: %v", err)
return fmt.Errorf("vacuum failed: %w", err)
}
return nil

View file

@ -38,7 +38,7 @@ func post45(ctx context.Context, db *sqlx.DB) error {
},
},
}); err != nil {
return err
return fmt.Errorf("failed to migrate images table for tags: %w", err)
}
if err := m.migrateImagesTable(ctx, migrateImagesTableOptions{
@ -52,7 +52,7 @@ func post45(ctx context.Context, db *sqlx.DB) error {
},
},
}); err != nil {
return err
return fmt.Errorf("failed to migrate images table for studios: %w", err)
}
if err := m.migrateImagesTable(ctx, migrateImagesTableOptions{
@ -66,7 +66,7 @@ func post45(ctx context.Context, db *sqlx.DB) error {
},
},
}); err != nil {
return err
return fmt.Errorf("failed to migrate images table for performers: %w", err)
}
if err := m.migrateImagesTable(ctx, migrateImagesTableOptions{
@ -80,7 +80,7 @@ func post45(ctx context.Context, db *sqlx.DB) error {
},
},
}); err != nil {
return err
return fmt.Errorf("failed to migrate images table for scenes: %w", err)
}
if err := m.migrateImagesTable(ctx, migrateImagesTableOptions{
@ -98,7 +98,7 @@ func post45(ctx context.Context, db *sqlx.DB) error {
},
},
}); err != nil {
return err
return fmt.Errorf("failed to migrate images table for movies: %w", err)
}
tablesToDrop := []string{
@ -111,12 +111,12 @@ func post45(ctx context.Context, db *sqlx.DB) error {
for _, table := range tablesToDrop {
if err := m.dropTable(ctx, table); err != nil {
return err
return fmt.Errorf("failed to drop table %s: %w", table, err)
}
}
if err := m.migrateConfig(ctx); err != nil {
return err
return fmt.Errorf("failed to migrate config: %w", err)
}
return nil

View file

@ -600,10 +600,10 @@ func runTests(m *testing.M) int {
err = populateDB()
if err != nil {
panic(fmt.Sprintf("Could not populate database: %s", err.Error()))
} else {
// run the tests
return m.Run()
}
// run the tests
return m.Run()
}
func populateDB() error {