aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/ensure.go
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-09-17 13:48:42 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-09-17 13:48:42 +0900
commit4b7d616862dc7d8c73561b85deb0ca1fabf30781 (patch)
treed069af086d1fcfeca2f9a629e0f3eb3e2f19500f /internal/app/ensure.go
parent6a6f62efa672bdb439c2f9056055193a53c1df01 (diff)
exit: move final and early code to internal package
Exit cleanup state information is now stored in a dedicated struct and built up using methods of that struct. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/app/ensure.go')
-rw-r--r--internal/app/ensure.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/internal/app/ensure.go b/internal/app/ensure.go
index ada6349f..ed283a94 100644
--- a/internal/app/ensure.go
+++ b/internal/app/ensure.go
@@ -8,29 +8,29 @@ import (
"path"
"git.ophivana.moe/cat/fortify/acl"
- "git.ophivana.moe/cat/fortify/internal/final"
+ "git.ophivana.moe/cat/fortify/internal"
"git.ophivana.moe/cat/fortify/internal/verbose"
)
func (a *App) EnsureRunDir() {
if err := os.Mkdir(a.runDirPath, 0700); err != nil && !errors.Is(err, fs.ErrExist) {
- final.Fatal("Error creating runtime directory:", err)
+ internal.Fatal("Error creating runtime directory:", err)
}
}
func (a *App) EnsureRuntime() {
if s, err := os.Stat(a.runtimePath); err != nil {
if errors.Is(err, fs.ErrNotExist) {
- final.Fatal("Runtime directory does not exist")
+ internal.Fatal("Runtime directory does not exist")
}
- final.Fatal("Error accessing runtime directory:", err)
+ internal.Fatal("Error accessing runtime directory:", err)
} else if !s.IsDir() {
- final.Fatal(fmt.Sprintf("Path '%s' is not a directory", a.runtimePath))
+ internal.Fatal(fmt.Sprintf("Path '%s' is not a directory", a.runtimePath))
} else {
if err = acl.UpdatePerm(a.runtimePath, a.UID(), acl.Execute); err != nil {
- final.Fatal("Error preparing runtime directory:", err)
+ internal.Fatal("Error preparing runtime directory:", err)
} else {
- final.RegisterRevertPath(a.runtimePath)
+ a.exit.RegisterRevertPath(a.runtimePath)
}
verbose.Printf("Runtime data dir '%s' configured\n", a.runtimePath)
}
@@ -39,7 +39,7 @@ func (a *App) EnsureRuntime() {
func (a *App) EnsureShare() {
// acl is unnecessary as this directory is world executable
if err := os.Mkdir(a.sharePath, 0701); err != nil && !errors.Is(err, fs.ErrExist) {
- final.Fatal("Error creating shared directory:", err)
+ internal.Fatal("Error creating shared directory:", err)
}
// workaround for launch method sudo
@@ -47,12 +47,12 @@ func (a *App) EnsureShare() {
// ensure child runtime directory (e.g. `/tmp/fortify.%d/%d.share`)
cr := path.Join(a.sharePath, a.Uid+".share")
if err := os.Mkdir(cr, 0700); err != nil && !errors.Is(err, fs.ErrExist) {
- final.Fatal("Error creating child runtime directory:", err)
+ internal.Fatal("Error creating child runtime directory:", err)
} else {
if err = acl.UpdatePerm(cr, a.UID(), acl.Read, acl.Write, acl.Execute); err != nil {
- final.Fatal("Error preparing child runtime directory:", err)
+ internal.Fatal("Error preparing child runtime directory:", err)
} else {
- final.RegisterRevertPath(cr)
+ a.exit.RegisterRevertPath(cr)
}
a.AppendEnv("XDG_RUNTIME_DIR", cr)
a.AppendEnv("XDG_SESSION_CLASS", "user")