From c6ca1ed7cbddfecdfec472008103d9a0525a180a Mon Sep 17 00:00:00 2001 From: Parham Alvani Date: Thu, 25 Jan 2024 01:46:14 +0000 Subject: [PATCH] Handle deleted streams (#162) * fix: handle deleted streams --- controllers/jetstream/stream.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/jetstream/stream.go b/controllers/jetstream/stream.go index b43059f4..f87277c8 100644 --- a/controllers/jetstream/stream.go +++ b/controllers/jetstream/stream.go @@ -92,7 +92,7 @@ func (c *Controller) processStreamObject(str *apis.Stream, jsm jsmClientFunc) (e // Write this to the cacheDir. accDir := filepath.Join(c.cacheDir, ns, spec.Account) - if err := os.MkdirAll(accDir, 0755); err != nil { + if err := os.MkdirAll(accDir, 0o755); err != nil { return err } @@ -101,7 +101,7 @@ func (c *Controller) processStreamObject(str *apis.Stream, jsm jsmClientFunc) (e remoteRootCA = filepath.Join(accDir, acc.Spec.TLS.RootCAs) for k, v := range secret.Data { - if err := os.WriteFile(filepath.Join(accDir, k), v, 0644); err != nil { + if err := os.WriteFile(filepath.Join(accDir, k), v, 0o644); err != nil { return err } } @@ -116,13 +116,13 @@ func (c *Controller) processStreamObject(str *apis.Stream, jsm jsmClientFunc) (e // Write the user credentials to the cache dir. accDir := filepath.Join(c.cacheDir, ns, spec.Account) - if err := os.MkdirAll(accDir, 0755); err != nil { + if err := os.MkdirAll(accDir, 0o755); err != nil { return err } for k, v := range secret.Data { if k == acc.Spec.Creds.File { accUserCreds = filepath.Join(c.cacheDir, ns, spec.Account, k) - if err := os.WriteFile(filepath.Join(accDir, k), v, 0644); err != nil { + if err := os.WriteFile(filepath.Join(accDir, k), v, 0o644); err != nil { return err } } @@ -207,7 +207,7 @@ func (c *Controller) processStreamObject(str *apis.Stream, jsm jsmClientFunc) (e return err } updateOK := (strOK && !deleteOK && newGeneration) - createOK := (!strOK && !deleteOK && newGeneration) + createOK := (!strOK && !deleteOK) || (!updateOK && !deleteOK && newGeneration) switch { case createOK: