Skip to content

Commit

Permalink
bugfix: ensure rust logs are cycled, ensure scripts are valid go files
Browse files Browse the repository at this point in the history
This requires the use of `strings.EqualFold` for bools used in the template
but this feels like a small price to pay for good IDE support.
  • Loading branch information
kegsay committed Mar 4, 2024
1 parent 2db970b commit bdc5b58
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/api/rust/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import (
"golang.org/x/exp/slices"
)

func DeleteOldLogs() {
func DeleteOldLogs(prefix string) {
// delete old log files
files, _ := os.ReadDir("./logs")
for _, f := range files {
if strings.HasPrefix(f.Name(), "rust_sdk_logs") {
if strings.HasPrefix(f.Name(), prefix) {
os.Remove(filepath.Join("./logs", f.Name()))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"strings"
"time"

"github.com/matrix-org/complement-crypto/internal/api"
Expand All @@ -17,7 +18,7 @@ func main() {
DeviceID: "{{.DeviceID}}",
Password: "{{.Password}}",
SlidingSyncURL: "{{.SSURL}}",
PersistentStorage: {{.PersistentStorage}},
PersistentStorage: strings.EqualFold("{{.PersistentStorage}}", "true"),
}
client, err := rust.NewRustClient(t, cfg)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"strings"
"time"

"github.com/matrix-org/complement-crypto/internal/api"
Expand All @@ -18,7 +19,7 @@ func main() {
DeviceID: "{{.DeviceID}}",
Password: "{{.Password}}",
SlidingSyncURL: "{{.SSURL}}",
PersistentStorage: {{.PersistentStorage}},
PersistentStorage: strings.EqualFold("{{.PersistentStorage}}", "true"),
}
client, err := rust.NewRustClient(t, cfg)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"strings"
"time"

"github.com/matrix-org/complement-crypto/internal/api"
Expand All @@ -18,7 +19,7 @@ func main() {
DeviceID: "{{.DeviceID}}",
Password: "{{.Password}}",
SlidingSyncURL: "{{.SSURL}}",
PersistentStorage: {{.PersistentStorage}},
PersistentStorage: strings.EqualFold("{{.PersistentStorage}}", "true"),
}
client, err := rust.NewRustClient(t, cfg)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func TestMain(m *testing.M) {
// TODO: ideally client packages would do this.
os.RemoveAll("./rust_storage")
os.RemoveAll("./chromedp")
rust.DeleteOldLogs()
rust.DeleteOldLogs("rust_sdk_logs")
rust.DeleteOldLogs("rust_sdk_inline_script")
rust.SetupLogs("rust_sdk_logs")

js.SetupJSLogs("./logs/js_sdk.log") // rust sdk logs on its own
Expand Down

0 comments on commit bdc5b58

Please sign in to comment.