Skip to content

Commit f78ce34

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/css-fixes
2 parents 936eff8 + efa93e8 commit f78ce34

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

backend/db/cron.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package db
22

33
import (
4+
"database/sql"
45
"fmt"
56
"github.com/robfig/cron/v3"
67
"hash/fnv"
@@ -116,7 +117,7 @@ func (task CronTask) getCronString() string {
116117
func (task CronTask) isLocked() bool {
117118
var lockedUntil time.Time
118119

119-
s := `SELECT locked_until FROM cron WHERE task_name=$1`
120+
s := `SELECT locked_until FROM cron WHERE task_name::text=$1`
120121
err := db.QueryRow(s, task.Name).Scan(&lockedUntil)
121122
if err != nil {
122123
log.Printf("Error checking locked_until for task '%s': %v\n", task.Name, err)
@@ -137,7 +138,7 @@ func (task CronTask) runCronTask() {
137138
lockUntil := time.Now().UTC().Add(-time.Second).Add(lockDuration)
138139

139140
err := db.QueryRow("SELECT pg_try_advisory_lock($1)", lockID).Scan(&lockAcquired)
140-
if err != nil {
141+
if err != nil && err != sql.ErrNoRows {
141142
log.Printf("Error acquiring advisory lock: %v\n", err)
142143
return
143144
}

backend/server/misc/handlers.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
// UpHandler is used as the health check endpoint for load balancing, docker, etc.
2121
func UpHandler(w http.ResponseWriter, _ *http.Request) {
2222
w.WriteHeader(http.StatusOK)
23+
_, _ = w.Write([]byte("OK"))
2324
}
2425

2526
// InfoHandler returns information about the current instance

backend/server/router.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ func (r *router) AddRoutes(routes []RouteDef) {
6262
func (r *router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
6363
for el, handler := range r.routes {
6464
if r.matchPath(el.Path, req.URL.Path) && el.Method == req.Method {
65-
log.Printf("%s %s\n", req.Method, req.URL)
65+
if req.URL.Path != string(endpoints.Up) {
66+
log.Printf("%s %s\n", req.Method, req.URL)
67+
}
68+
6669
handler(w, req)
6770
return
6871
}

cli/commands/auth/login/view.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func showTwoFactorPrompt() string {
154154
huh.NewConfirm().Affirmative("Submit").Negative(""),
155155
)).WithTheme(styles.Theme).Run()
156156

157-
return code
157+
return strings.TrimSpace(code)
158158
}
159159

160160
func showCLISessionNote(sessionKey string) {

cli/commands/auth/signup/view.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,11 @@ func showCaptchaModel(captchaStr string, errorMessages ...string) string {
253253
converter := convert.NewImageConverter()
254254
options := convert.DefaultOptions
255255
options.Colored = false
256+
options.FixedHeight = 40
257+
options.FixedWidth = 80
256258

257259
codeStr := converter.Image2ASCIIString(img, &options)
260+
codeStr = shared.TrimEmptyLines(codeStr)
258261

259262
var code string
260263

@@ -276,7 +279,7 @@ func showCaptchaModel(captchaStr string, errorMessages ...string) string {
276279
).WithTheme(styles.Theme).Run()
277280
utils.HandleCLIError("", err)
278281

279-
return code
282+
return strings.TrimSpace(code)
280283
}
281284

282285
// showAccountConfirmationModel displays the user's new account ID to the user

cli/commands/download/view.go

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ func showDownloadFileModel(prep PreparedDownload, filename string) {
178178
progress := int((float32(chunk) / float32(p.NumChunks)) * 100)
179179
msg := fmt.Sprintf("Downloading file... (%d%%)", progress)
180180
downloadSpinner.Title(msg)
181+
chunk++
181182
})
182183
}).Run()
183184

shared/utils.go

+16
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,19 @@ func ObscureEmail(email string) (string, error) {
220220

221221
return hiddenEmail, nil
222222
}
223+
224+
func TrimEmptyLines(s string) string {
225+
lines := strings.Split(s, "\n")
226+
227+
start := 0
228+
for start < len(lines) && strings.TrimSpace(lines[start]) == "" {
229+
start++
230+
}
231+
232+
end := len(lines)
233+
for end > start && strings.TrimSpace(lines[end-1]) == "" {
234+
end--
235+
}
236+
237+
return strings.Join(lines[start:end], "\n")
238+
}

0 commit comments

Comments
 (0)