aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap/observer.go
Commit message (Collapse)AuthorAgeFilesLines
* lint: update golangci-lint to 1.61.0Tristan Partin2024-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | golangci-lint 1.56 does not work with go 1.23. It causes obscure errors: [linters_context/goanalysis] buildir: panic during analysis: Cannot range over: func(yield func(K, V) bool), goroutine 4743 [running]: runtime/debug.Stack() /usr/lib/go/src/runtime/debug/stack.go:26 +0x5e github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1() /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_action.go:104 +0x5a panic({0x164b260?, 0xc00669b4a0?}) /usr/lib/go/src/runtime/panic.go:785 +0x132 honnef.co/go/tools/go/ir.(*builder).rangeStmt(0xc000051910, 0xc00a29cf00, 0xc009bf55c0, 0x0, {0x1af1960, 0xc009bf55c0}) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2214 +0x894 honnef.co/go/tools/go/ir.(*builder).stmt(0xc000051910, 0xc00a29cf00, {0x1af6970?, 0xc009bf55c0?}) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2427 +0x20a honnef.co/go/tools/go/ir.(*builder).stmtList(...) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:847 honnef.co/go/tools/go/ir.(*builder).stmt(0xc000051910, 0xc00a29cf00, {0x1af6880?, 0xc004f52ed0?}) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2385 +0x1415 honnef.co/go/tools/go/ir.(*builder).buildFunction(0xc000051910, 0xc00a29cf00) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2497 +0x417 honnef.co/go/tools/go/ir.(*builder).buildFuncDecl(0xc000051910, 0xc00622eea0, 0xc004f52f00) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2534 +0x189 honnef.co/go/tools/go/ir.(*Package).build(0xc00622eea0) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2638 +0xb46 sync.(*Once).doSlow(0xc009b81260?, 0xc009bf5bc0?) /usr/lib/go/src/sync/once.go:76 +0xb4 sync.(*Once).Do(...) /usr/lib/go/src/sync/once.go:67 honnef.co/go/tools/go/ir.(*Package).Build(...) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/go/ir/builder.go:2556 honnef.co/go/tools/internal/passes/buildir.run(0xc000cf61a0) /home/build/go/pkg/mod/honnef.co/go/tools@v0.4.6/internal/passes/buildir/buildir.go:86 +0x18b github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc002d77d70) /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_action.go:190 +0x9cd github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2() /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_action.go:112 +0x17 github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc0007a5c70, {0x1859190, 0x7}, 0xc001c28f48) /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/timeutils/stopwatch.go:111 +0x44 github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc00212f680?) /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_action.go:111 +0x6e github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc002d77d70) /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xa5 created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze in goroutine 3468 /home/build/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.1/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1e9 Update golangci-lint to 1.61.0 that works with go 1.23. It has new checkers that report errors that we need to fix: lib/crypto/gpg/gpgbin/gpgbin.go:226:22: printf: non-constant format string in call to fmt.Errorf (govet) return fmt.Errorf(strings.TrimPrefix(line, "[GNUPG:] ")) ^ worker/imap/observer.go:142:21: printf: non-constant format string in call to fmt.Errorf (govet) Error: fmt.Errorf(errMsg), ^ app/dirlist.go:409:5: S1009: should omit nil check; len() for []string is defined as zero (gosimple) if dirlist.dirs == nil || len(dirlist.dirs) == 0 { ^ app/dirtree.go:181:5: S1009: should omit nil check; len() for []*git.sr.ht/~rjarry/aerc/worker/types.Thread is defined as zero (gosimple) if dt.list == nil || len(dt.list) == 0 || dt.countVisible(dt.list) < y+dt.Scroll() { ^ app/authinfo.go:30:34: printf: non-constant format string in call to (*git.sr.ht/~rjarry/aerc/lib/ui.Context).Printf (govet) ctx.Printf(0, 0, defaultStyle, text) ^ app/authinfo.go:34:27: printf: non-constant format string in call to (*git.sr.ht/~rjarry/aerc/lib/ui.Context).Printf (govet) ctx.Printf(0, 0, style, text) ^ app/authinfo.go:62:34: printf: non-constant format string in call to (*git.sr.ht/~rjarry/aerc/lib/ui.Context).Printf (govet) x += ctx.Printf(x, 0, style, text) ^ Pretty much all of these errors are us passing non-const format strings to various methods. In C land, this is a large security issue. I would assume the same stands in Go. Thank you golangci-lint! Link: https://builds.sr.ht/~rjarry/job/1332376#task-validate-500 Signed-off-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>
* log: move package to libRobin Jarry2024-02-141-1/+1
| | | | | | | This has nothing to do at the root of the source tree. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* idler: improve the imap idlerKoni Marti2024-01-251-3/+0
| | | | | | | | | | Rewrite the imap idler to make it more fault tolerant and prevent hangs (and possibly short writes). Fixes: https://todo.sr.ht/~rjarry/aerc/208 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Karel Balej <balejk@matfyz.cz> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: add folder-mapKoni Marti2023-06-221-2/+2
| | | | | | | | | Add the folder-map functionality to the imap backend. If the folder-map config option is specified, the folder-map worker middleware is used. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* logging: remove ultra verbose trace logsRobin Jarry2023-06-121-5/+1
| | | | | | | | | | | | | | | | | Every message exchanged between the UI and the worker(s) is logged at least twice with some obscure IDs and struct pointer names. When enabling trace logging, this floods the files for very little or no benefit and makes the meaningful logging message hard to catch. Also, other messages tend to flood the output for no specific reason. These are most of the time leftovers from the development process and are not useful for tracking potential issues. Remove these. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* imap: use named loggerRobin Jarry2023-06-121-1/+1
| | | | | | | | Use the worker's logging functions to have all imap related messages prefixed by the account name. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* lint: add missing panic handlers in goroutinesRobin Jarry2023-01-061-0/+2
| | | | | | | | These issues were all reported by the new custom analyzer introduced in previous commit. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* logging: rename package to logRobin Jarry2022-12-021-2/+2
| | | | | | | | | | Use the same name than the builtin "log" package. That way, we do not risk logging in the wrong place. Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* logging: homogenize levelsRobin Jarry2022-12-021-1/+1
| | | | | | | | | | | | | | | | | | The main goal is to ensure that by default, the log file (if configured) does not grow out of proportions. Most of the logging messages in aerc are actually for debugging and/or trace purposes. Define clear rules for logging levels. Enforce these rules everywhere. After this patch, here is what the log file looks like after starting up with a single account: INFO 2022/11/24 20:26:16.147164 aerc.go:176: Starting up version 0.13.0-100-g683981479c60 (go1.18.7 amd64 linux) INFO 2022/11/24 20:26:17.546448 account.go:254: [work] connected. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* lint: apply new formatting rulesMoritz Poldrack2022-08-011-1/+2
| | | | | | | Run `make fmt`. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* logging: use level-based logger functionsRobin Jarry2022-07-231-3/+4
| | | | | | | | | | | | Do not pass logger objects around anymore. Shuffle some messages to make them consistent with the new logging API. Avoid using %v when a more specific verb exists for the argument types. The loggers are completely disabled (i.e. Sprintf is not even called) by default. They are only enabled when redirecting stdout to a file. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* imap: monitor the logout channel with an observerKoni Marti2022-05-041-0/+152
Untangle the observer functionality from the message handling routine. Observe the imap client's logout channel and trigger a connection error when necessary to start the reconnect cycle. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>