Skip to content

Commit

Permalink
Handle deleted streams (#162)
Browse files Browse the repository at this point in the history
* fix: handle deleted streams
  • Loading branch information
1995parham authored Jan 25, 2024
1 parent ba66484 commit c6ca1ed
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions controllers/jetstream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c6ca1ed

Please sign in to comment.