Consolidate the data directory mode into one owner #318

Merged
clawbot merged 1 commits from issue-288-datadir-mode-owner into next 2026-09-21 10:01:51 +02:00
Collaborator

Two constants defined the data directory mode (0o750) in two packages that both create DATA_DIR: internal/datadir and internal/database. They agreed, but nothing kept them agreeing.

This makes internal/datadir the single owner. Its dirPerm becomes an exported DirPerm, and internal/database consumes it in both spots that create the directory (database.go and webhook_db_manager.go), dropping its own dataDirPerm.

Why datadir owns it: guarding and creating DATA_DIR is the package's entire purpose. The dependency direction allows it — datadir imports only the standard library and the flock package, so database importing datadir introduces no cycle. The reverse would not fit, since datadir must stay free of the database package it protects.

Single-source guard: a comment on DirPerm names it as the one definition. I chose that over a test that scans the tree for a reappearing literal, because the comment survives refactoring and adds no machinery that inspects the tree instead of fixing it — matching the definition of done's "whichever is more likely to survive."

No behaviour changes: the mode value is identical, so directory permissions are unchanged.

Resolves #288

Model: opus-4-8

Two constants defined the data directory mode (`0o750`) in two packages that both create `DATA_DIR`: `internal/datadir` and `internal/database`. They agreed, but nothing kept them agreeing. This makes `internal/datadir` the single owner. Its `dirPerm` becomes an exported `DirPerm`, and `internal/database` consumes it in both spots that create the directory (`database.go` and `webhook_db_manager.go`), dropping its own `dataDirPerm`. Why `datadir` owns it: guarding and creating `DATA_DIR` is the package's entire purpose. The dependency direction allows it — `datadir` imports only the standard library and the flock package, so `database` importing `datadir` introduces no cycle. The reverse would not fit, since `datadir` must stay free of the `database` package it protects. Single-source guard: a comment on `DirPerm` names it as the one definition. I chose that over a test that scans the tree for a reappearing literal, because the comment survives refactoring and adds no machinery that inspects the tree instead of fixing it — matching the definition of done's "whichever is more likely to survive." No behaviour changes: the mode value is identical, so directory permissions are unchanged. Resolves https://git.eeqj.de/sneak/webhooker/issues/288 Model: opus-4-8
clawbot added 1 commit 2026-09-21 09:49:09 +02:00
internal/datadir now owns the DATA_DIR mode as an exported constant,
DirPerm; internal/database consumes it in both places that create the
directory rather than keeping its own copy. datadir is the owner
because guarding and creating DATA_DIR is its whole purpose, and the
dependency runs the right way: datadir imports only the standard
library and the flock package, so database importing datadir adds no
cycle. A comment on DirPerm names it as the single source, chosen over
a source-scanning test because it survives refactoring and builds no
machinery that inspects the tree. The mode value is unchanged.

Model: opus-4-8
clawbot added the needs-review label 2026-09-21 09:49:18 +02:00
clawbot self-assigned this 2026-09-21 09:49:18 +02:00
Author
Collaborator

Consolidation is correct and minimal: internal/datadir exports DirPerm, internal/database consumes it in both directory-creating spots, the value is unchanged, the dependency direction is sound (datadir imports only the standard library and the flock package, so no cycle), the comment naming the single source is accurate, and make check is green on the head rebased onto current next.

Model: opus-4-8

Consolidation is correct and minimal: `internal/datadir` exports `DirPerm`, `internal/database` consumes it in both directory-creating spots, the value is unchanged, the dependency direction is sound (`datadir` imports only the standard library and the flock package, so no cycle), the comment naming the single source is accurate, and `make check` is green on the head rebased onto current `next`. Model: opus-4-8
clawbot merged commit 39afa69bfc into next 2026-09-21 10:01:51 +02:00
clawbot deleted branch issue-288-datadir-mode-owner 2026-09-21 10:01:52 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#318