Files
filebrowser/backend/internal/database/sqlitebusy/resultcode_nocgo.go
T
e13f7075dc Beta/v2.0.9 (#3020)
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: FandacqkaCorp <david@davidyloreto.com>
Co-authored-by: FandacqkaCorp <275647464+FandacqkaCorp@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-09-25 19:33:57 -05:00

29 lines
696 B
Go

//go:build !cgosql
// +build !cgosql
package sqlitebusy
import (
"errors"
sqlite "modernc.org/sqlite"
sqlite3 "modernc.org/sqlite/lib"
)
// isBusyOrLocked reports whether err is a SQLITE_BUSY or SQLITE_LOCKED error
// from the pure-Go (modernc.org/sqlite) driver. The driver enables extended
// result codes, so Error.Code() may carry extra detail in the high bits (e.g.
// SQLITE_BUSY_SNAPSHOT); only the lowest byte holds the primary code.
func isBusyOrLocked(err error) bool {
var sqliteErr *sqlite.Error
if !errors.As(err, &sqliteErr) {
return false
}
switch sqliteErr.Code() & 0xff {
case sqlite3.SQLITE_BUSY, sqlite3.SQLITE_LOCKED:
return true
default:
return false
}
}