Skip to content

Commit 56babb8

Browse files
danishedbDanish Khanleonardocefcanovaimnencia
authored
fix: error management when removing not existing directories
Co-authored-by: Danish Khan <danish.khan@Danishs-MacBook-Pro.local> Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com> Co-authored-by: Francesco Canovai <francesco.canovai@enterprisedb.com> Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent ef7ad4b commit 56babb8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/management/postgres/pidfile.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ func (instance *Instance) CheckForExistingPostmaster(postgresExecutable string)
9191
// cleanUpStalePid is called to clean up the files left around by a crashed PostgreSQL instance.
9292
// It removes the PostgreSQL pid file and the content of the socket directory.
9393
func (instance *Instance) cleanUpStalePid(pidFile string) error {
94-
if err := os.Remove(pidFile); err != nil {
94+
if err := os.Remove(pidFile); err != nil && !os.IsNotExist(err) {
9595
return err
9696
}
9797

98-
return fileutils.RemoveDirectoryContent(instance.SocketDirectory)
98+
if err := fileutils.RemoveDirectoryContent(instance.SocketDirectory); err != nil && !os.IsNotExist(err) {
99+
return err
100+
}
101+
102+
return nil
99103
}

0 commit comments

Comments
 (0)