Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Merge release channels into the account database and rename it instance.db

3047be84e9bce79372051c09854ce9b05f12a9bf · Keenan Nemetz · 17d ago · parent 262e516e

Merge release channels into the account database and rename it instance.db

The instance keeps four SQLite files instead of five. Release channels were in a
file of their own only because they were added beside the derived index; they are
authoritative source state, like the roster, so they belong in the file an
operator restores. Nothing has to be migrated: channels.db never shipped in a
release, so only an instance tracking main can have one.

The account database is now data/instance.db. The package comments already called
it that; only the filename disagreed.

Moving an existing instance is an operator step, by decision: a rename under a
live server can lose the -wal file a hook subprocess still has open. Vole refuses
to start while data/users.db is still in place, and says what to move, rather
than creating an empty database beside it that would look like a successful
upgrade.

The list of databases now lives in Config.Databases, which TightenSecrets, the
hook plumbing, and the admin commands read, so a missed -wal file is no longer a
nine-file change. `vole admin account backup <path>` becomes `vole admin db
backup <dir>` and covers every authoritative database; `db list` and `db check`
answer what to back up and whether it is intact.

server/hook/hook.go +12−11

@@ -33,9 +33,10 @@ type Config struct {
33 33 // credential may write less than the account it acts as.
34 34 KeyID string
35 35 MaxBlobBytes int64
36 // UsersDB, when set, is the roster database, read here for access rules and
37 // file locks. Attribution itself is the Actor name resolved at the handshake.
38 UsersDB string
36 // InstanceDB, when set, is the instance database, read here for access rules,
37 // account standing and file locks. Attribution itself is the Actor name
38 // resolved at the handshake.
39 InstanceDB string
39 40 // SpoolDir receives one file per accepted ref update, for the CI queue.
40 41 SpoolDir string
41 42 // RunsDB is the run queue, read here so required checks are enforced at the
@@ -89,18 +90,18 @@ func PreReceive(cfg Config) int {
89 90 lockTable *lfs.LockStore
90 91 err error
91 92 )
92 if cfg.UsersDB != "" {
93 acls, err = access.Open(cfg.UsersDB)
93 if cfg.InstanceDB != "" {
94 acls, err = access.Open(cfg.InstanceDB)
94 95 if err != nil {
95 96 reject(cfg.Out, "cannot open the access rules: %v", err)
96 97 return 1
97 98 }
98 99 defer acls.Close()
99 // The push gate runs as a separate process, so it opens the roster itself
100 // to learn the actor's instance-wide role. Without this the hook would
101 // enforce only repository entries and silently ignore an invitation that
102 // granted contribute everywhere.
103 ident, err := identity.Open(cfg.UsersDB)
100 // The push gate runs as a separate process, so it opens the instance
101 // database itself to learn the actor's instance-wide role. Without this the
102 // hook would enforce only repository entries and silently ignore an
103 // invitation that granted contribute everywhere.
104 ident, err := identity.Open(cfg.InstanceDB)
104 105 if err != nil {
105 106 reject(cfg.Out, "cannot open the roster: %v", err)
106 107 return 1
@@ -112,7 +113,7 @@ func PreReceive(cfg Config) int {
112 113 acls.Active = ident.Active
113 114 // The lock table shares that database, so the push path learns what is held
114 115 // without a second endpoint and without the client's cooperation.
115 lockTable, err = lfs.OpenLocks(cfg.UsersDB)
116 lockTable, err = lfs.OpenLocks(cfg.InstanceDB)
116 117 if err != nil {
117 118 reject(cfg.Out, "cannot open the lock table: %v", err)
118 119 return 1