commit 5af558a
chld
·
2026-02-07 17:12:09 +0000 UTC
parent e1a2b2f
stop duplicates in install file?
1 files changed,
+6,
-0
+6,
-0
1@@ -4,6 +4,7 @@ import (
2 "git.sr.ht/~chld/dgr/cmd"
3 "os"
4 "path/filepath"
5+ "strings"
6 )
7
8 func Inst(pkg string) {
9@@ -24,6 +25,11 @@ func Inst(pkg string) {
10 } else {
11 // write the installed package to a installed file for tracking
12
13+ fx, _ := os.ReadFile(filepath.Join(os.Getenv("DTR_DB"), "installed"))
14+ if strings.Contains(string(fx), pkg) {
15+ return // we already see the package installed, no need to write again
16+ }
17+
18 f, err := os.OpenFile(
19 filepath.Join(os.Getenv("DTR_DB"), "installed"),
20 os.O_WRONLY|os.O_APPEND, 0644) // make sure to append, r/w access