internal/sys/hsu: expose hsurc identifier
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Hakurei (push) Successful in 3m10s
Test / Hpkg (push) Successful in 4m5s
Test / Sandbox (race detector) (push) Successful in 4m35s
Test / Hakurei (race detector) (push) Successful in 5m17s
Test / Sandbox (push) Successful in 1m16s
Test / Flake checks (push) Successful in 1m24s

This maintains a compatible interface for now, to ease merging of the upcoming changes to internal/app.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-09-24 21:17:04 +09:00
parent afa7a0800d
commit 65a0bb9729
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q

View File

@ -24,7 +24,8 @@ type Hsu struct {
var ErrHsuAccess = errors.New("current user is not in the hsurc file")
func (h *Hsu) Uid(identity int) (int, error) {
// ID returns the current user hsurc identifier. ErrHsuAccess is returned if the current user is not in hsurc.
func (h *Hsu) ID() (int, error) {
h.idOnce.Do(func() {
h.id = -1
hsuPath := internal.MustHsuPath()
@ -54,11 +55,15 @@ func (h *Hsu) Uid(identity int) (int, error) {
}
})
uid := -1
if h.id >= 0 {
uid = 1000000 + h.id*10000 + identity
return h.id, h.idErr
}
return uid, h.idErr
func (h *Hsu) Uid(identity int) (int, error) {
id, err := h.ID()
if err == nil {
return 1000000 + id*10000 + identity, nil
}
return id, err
}
// MustUid calls [State.Uid] and terminates on error.