Skip to content

Commit

Permalink
Optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Aug 23, 2023
1 parent 3915e83 commit 30089be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/internal/database/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (db *Postgres) Backup() error {
// therefore this happens in the backup task where the database is already available
//
// implication: one backup has to be taken before an upgrade can be made
err := db.copyPostgresBinaries()
err := db.copyPostgresBinaries(false)
if err != nil {
return err
}
Expand Down
11 changes: 9 additions & 2 deletions cmd/internal/database/postgres/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (db *Postgres) Upgrade() error {
}

// If this is a database directory, save actual postgres binaries for a later major upgrade
err := db.copyPostgresBinaries()
err := db.copyPostgresBinaries(true)
if err != nil {
return err
}
Expand Down Expand Up @@ -265,12 +265,19 @@ func (db *Postgres) getBinDir(pgConfigCmd string) (string, error) {
}

// copyPostgresBinaries is needed to save old postgres binaries for a later major upgrade
func (db *Postgres) copyPostgresBinaries() error {
func (db *Postgres) copyPostgresBinaries(override bool) error {
binDir, err := db.getBinDir(postgresConfigCmd)
if err != nil {
return err
}

if !override {
if _, err := os.Stat(path.Join(binDir, postgresConfigCmd)); err == nil {
db.log.Info("postgres binaries for later upgrade already in place, not copying")
return nil
}
}

version, err := db.getBinaryVersion(postgresConfigCmd)
if err != nil {
return err
Expand Down

0 comments on commit 30089be

Please sign in to comment.