Consolidate the data directory mode into one owner (closes #288)
check / check (push) Successful in 6m34s
check / check (push) Successful in 6m34s
Two packages each declared the 0o750 mode for DATA_DIR and both created the directory. internal/datadir now exports DirPerm as the single definition, and internal/database uses it in both places it creates the directory. The value is unchanged, so existing deployments see no permission change. datadir owns it because guarding and creating DATA_DIR is that package's whole purpose and it imports nothing that would form a cycle. Model: opus-4-8 (implementation and review); fable-5-1 (merge)
This commit was merged in pull request #318.
This commit is contained in:
@@ -29,9 +29,11 @@ import (
|
||||
// process that was killed with SIGKILL blocks nothing.
|
||||
const LockFileName = "webhooker.lock"
|
||||
|
||||
// dirPerm is the mode Acquire creates DATA_DIR with. It matches what
|
||||
// internal/database uses, since whichever runs first creates it.
|
||||
const dirPerm = 0o750
|
||||
// DirPerm is the mode DATA_DIR is created with. It is the single
|
||||
// source of that mode: internal/database consumes it rather than
|
||||
// keeping its own copy, so the two packages that both create the
|
||||
// directory cannot drift into disagreeing about its permissions.
|
||||
const DirPerm = 0o750
|
||||
|
||||
// ErrLocked reports that another live process holds the data
|
||||
// directory. Callers that need to know whether a deployment is running
|
||||
@@ -64,7 +66,7 @@ func Acquire(dir string) (*Lock, error) {
|
||||
return nil, ErrNoDir
|
||||
}
|
||||
|
||||
err := os.MkdirAll(dir, dirPerm)
|
||||
err := os.MkdirAll(dir, DirPerm)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"creating data directory %s: %w", dir, err,
|
||||
|
||||
Reference in New Issue
Block a user