From 0f6803f8906ce875d8e188c9ffffafeb57c66a77 Mon Sep 17 00:00:00 2001 From: Tom Wiesing Date: Sat, 8 Apr 2023 17:51:17 +0200 Subject: [PATCH] Use fsx package and friends from pkglib --- cmd/bootstrap.go | 17 +- cmd/monday.go | 4 +- cmd/reserve.go | 2 +- cmd/system_update.go | 7 +- go.mod | 2 +- go.sum | 4 +- internal/cli/meta.go | 4 +- internal/config/paths.go | 6 +- internal/config/validators/files.go | 4 +- internal/dis/component/auth/user.go | 7 +- internal/dis/component/backup.go | 10 +- internal/dis/component/exporter/backup.go | 6 +- internal/dis/component/exporter/exporter.go | 5 +- internal/dis/component/exporter/iface.go | 8 +- internal/dis/component/exporter/report.go | 13 +- internal/dis/component/provision/provision.go | 2 +- internal/dis/component/server/home/public.go | 6 +- internal/dis/component/server/news/news.go | 6 +- .../dis/component/server/templating/base.go | 8 +- internal/dis/component/sql/sql.go | 4 +- .../dis/component/ssh2/server_hostkeys.go | 4 +- internal/dis/component/stack.go | 14 +- .../dis/component/triplestore/database.go | 9 +- .../dis/component/triplestore/provision.go | 7 +- internal/status/wisski_user.go | 16 +- .../wisski/ingredient/php/extras/prefixes.go | 6 +- pkg/fsx/copy.go | 150 ------------------ pkg/fsx/create.go | 57 ------- pkg/fsx/dir.go | 25 --- pkg/fsx/fsx.go | 37 ----- pkg/fsx/same.go | 89 ----------- pkg/fsx/type.go | 31 ---- pkg/targz/targz.go | 4 +- pkg/unpack/resource.go | 6 +- pkg/unpack/template.go | 4 +- 35 files changed, 91 insertions(+), 493 deletions(-) delete mode 100644 pkg/fsx/copy.go delete mode 100644 pkg/fsx/create.go delete mode 100644 pkg/fsx/dir.go delete mode 100644 pkg/fsx/fsx.go delete mode 100644 pkg/fsx/same.go delete mode 100644 pkg/fsx/type.go diff --git a/cmd/bootstrap.go b/cmd/bootstrap.go index c00df19..7625969 100644 --- a/cmd/bootstrap.go +++ b/cmd/bootstrap.go @@ -10,9 +10,10 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/cli" "github.com/FAU-CDI/wisski-distillery/internal/config" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/logging" "github.com/tkw1536/goprogram/exit" + "github.com/tkw1536/pkglib/fsx" + "github.com/tkw1536/pkglib/fsx/umaskfree" ) // Bootstrap is the 'bootstrap' command @@ -81,7 +82,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error { { logging.LogMessage(context.Stderr, "Creating root deployment directory") - if err := fsx.MkdirAll(root, fsx.DefaultDirPerm); err != nil { + if err := umaskfree.MkdirAll(root, umaskfree.DefaultDirPerm); err != nil { return errBootstrapFailedToCreateDirectory.WithMessageF(root).Wrap(err) } if err := cli.WriteBaseDirectory(root); err != nil { @@ -111,22 +112,22 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error { return errBoostrapFailedToCopyExe.WithMessageF(err) } - err = fsx.CopyFile(context.Context, wdcliPath, exe) - if err != nil && err != fsx.ErrCopySameFile { + err = umaskfree.CopyFile(context.Context, wdcliPath, exe) + if err != nil && err != umaskfree.ErrCopySameFile { return errBoostrapFailedToCopyExe.WithMessageF(err) } context.Println(wdcliPath) } { - if !fsx.IsFile(cfgPath) { + if !fsx.IsRegular(cfgPath) { // generate the configuration from the template cfg := tpl.Generate() // write out all the extra config files if err := logging.LogOperation(func() error { context.Println(cfg.Paths.OverridesJSON) - if err := fsx.WriteFile( + if err := umaskfree.WriteFile( cfg.Paths.OverridesJSON, bootstrap.DefaultOverridesJSON, fs.ModePerm, @@ -135,7 +136,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error { } context.Println(cfg.Paths.ResolverBlocks) - if err := fsx.WriteFile( + if err := umaskfree.WriteFile( cfg.Paths.ResolverBlocks, bootstrap.DefaultResolverBlockedTXT, fs.ModePerm, @@ -155,7 +156,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error { // and marshal it out! if err := logging.LogOperation(func() error { - configYML, err := fsx.Create(cfgPath, fsx.DefaultFilePerm) + configYML, err := umaskfree.Create(cfgPath, umaskfree.DefaultFilePerm) if err != nil { return err } diff --git a/cmd/monday.go b/cmd/monday.go index d241c36..bf5db7a 100644 --- a/cmd/monday.go +++ b/cmd/monday.go @@ -3,8 +3,8 @@ package cmd import ( wisski_distillery "github.com/FAU-CDI/wisski-distillery" "github.com/FAU-CDI/wisski-distillery/internal/cli" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/logging" + "github.com/tkw1536/pkglib/fsx" ) // Monday is the 'monday' command @@ -28,7 +28,7 @@ func (monday) Description() wisski_distillery.Description { } func (monday monday) AfterParse() error { - if !fsx.IsFile(monday.Positionals.GraphdbZip) { + if !fsx.IsRegular(monday.Positionals.GraphdbZip) { return errNoGraphDBZip.WithMessageF(monday.Positionals.GraphdbZip) } return nil diff --git a/cmd/reserve.go b/cmd/reserve.go index 7d87a01..91f8894 100644 --- a/cmd/reserve.go +++ b/cmd/reserve.go @@ -4,9 +4,9 @@ import ( wisski_distillery "github.com/FAU-CDI/wisski-distillery" "github.com/FAU-CDI/wisski-distillery/internal/cli" "github.com/FAU-CDI/wisski-distillery/internal/dis/component" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/logging" "github.com/tkw1536/goprogram/exit" + "github.com/tkw1536/pkglib/fsx" ) // Reserve is the 'reserve' command diff --git a/cmd/system_update.go b/cmd/system_update.go index d87e4cd..a9e3eb4 100644 --- a/cmd/system_update.go +++ b/cmd/system_update.go @@ -9,10 +9,11 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/cli" "github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/pkg/execx" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/logging" "github.com/tkw1536/goprogram/exit" "github.com/tkw1536/goprogram/parser" + "github.com/tkw1536/pkglib/fsx" + "github.com/tkw1536/pkglib/fsx/umaskfree" "github.com/tkw1536/pkglib/status" ) @@ -46,7 +47,7 @@ var errNoGraphDBZip = exit.Error{ func (s systemupdate) AfterParse() error { // TODO: Use a generic environment here! - if !fsx.IsFile(s.Positionals.GraphdbZip) { + if !fsx.IsRegular(s.Positionals.GraphdbZip) { return errNoGraphDBZip.WithMessageF(s.Positionals.GraphdbZip) } return nil @@ -92,7 +93,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) (err error) { dis.Templating().CustomAssetsPath(), } { context.Println(d) - if err := fsx.MkdirAll(d, fsx.DefaultDirPerm); err != nil { + if err := umaskfree.MkdirAll(d, umaskfree.DefaultDirPerm); err != nil { return errBoostrapFailedToCreateDirectory.WithMessageF(d).Wrap(err) } } diff --git a/go.mod b/go.mod index 273ba7f..bd03c44 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/pquerna/otp v1.4.0 github.com/rs/zerolog v1.29.0 github.com/tkw1536/goprogram v0.3.5 - github.com/tkw1536/pkglib v0.0.0-20230319133918-3edc36187874 + github.com/tkw1536/pkglib v0.0.0-20230408155139-3ef777879e0f github.com/yuin/goldmark v1.5.4 github.com/yuin/goldmark-meta v1.1.0 golang.org/x/crypto v0.7.0 diff --git a/go.sum b/go.sum index b8e5073..67630bd 100644 --- a/go.sum +++ b/go.sum @@ -115,8 +115,8 @@ github.com/tdewolff/parse v2.3.4+incompatible/go.mod h1:8oBwCsVmUkgHO8M5iCzSIDtp github.com/tdewolff/test v1.0.7 h1:8Vs0142DmPFW/bQeHRP3MV19m1gvndjUb1sn8yy74LM= github.com/tkw1536/goprogram v0.3.5 h1:S0axKo3R/vGa4zhYqYDKAZEPhAfwUSSeMtVwnAu4sNY= github.com/tkw1536/goprogram v0.3.5/go.mod h1:pYr4dMHOSVurbPQ4KTR0ett8XWNISbsRS6zlh9Nsxa8= -github.com/tkw1536/pkglib v0.0.0-20230319133918-3edc36187874 h1:BrsHJnkecpO1OOXiuFcJG2t4EiaLhhMdLMrfPldYWl4= -github.com/tkw1536/pkglib v0.0.0-20230319133918-3edc36187874/go.mod h1:RjPEyRcq+g1GMd3D/o7d9WCtVNXY4QZyFRs9hLlZbew= +github.com/tkw1536/pkglib v0.0.0-20230408155139-3ef777879e0f h1:sGb/t/cM2extjiArB6q0Yx1f4IK2NyZ5Kw3lP2w8Vg4= +github.com/tkw1536/pkglib v0.0.0-20230408155139-3ef777879e0f/go.mod h1:RjPEyRcq+g1GMd3D/o7d9WCtVNXY4QZyFRs9hLlZbew= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= diff --git a/internal/cli/meta.go b/internal/cli/meta.go index dd5fbcf..597c836 100644 --- a/internal/cli/meta.go +++ b/internal/cli/meta.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/FAU-CDI/wisski-distillery/internal/bootstrap" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" + "github.com/tkw1536/pkglib/fsx/umaskfree" ) // metaConfigFile is the path to a configuration file that contains the path to the last used wdcli executable. @@ -68,5 +68,5 @@ func WriteBaseDirectory(dir string) error { } // just put the directory inside it! - return fsx.WriteFile(path, []byte(dir), fs.ModePerm) + return umaskfree.WriteFile(path, []byte(dir), fs.ModePerm) } diff --git a/internal/config/paths.go b/internal/config/paths.go index 57b3b78..ac69793 100644 --- a/internal/config/paths.go +++ b/internal/config/paths.go @@ -5,7 +5,7 @@ import ( "path/filepath" "github.com/FAU-CDI/wisski-distillery/internal/bootstrap" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" + "github.com/tkw1536/pkglib/fsx" ) type PathsConfig struct { @@ -38,14 +38,14 @@ func (pcfg PathsConfig) UsingDistilleryExecutable() bool { if err != nil { return false } - return fsx.SameFile(exe, pcfg.ExecutablePath()) + return fsx.Same(exe, pcfg.ExecutablePath()) } // CurrentExecutable returns the path to the current executable being used. // When it does not exist, falls back to the default executable. func (pcfg PathsConfig) CurrentExecutable() string { exe, err := os.Executable() - if err != nil || !fsx.IsFile(exe) { + if err != nil || !fsx.IsRegular(exe) { return pcfg.ExecutablePath() } return exe diff --git a/internal/config/validators/files.go b/internal/config/validators/files.go index e1fc39d..b765f8c 100644 --- a/internal/config/validators/files.go +++ b/internal/config/validators/files.go @@ -1,15 +1,15 @@ package validators import ( - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/pkg/errors" + "github.com/tkw1536/pkglib/fsx" ) func ValidateFile(path *string, dflt string) error { if *path == "" { *path = dflt } - if !fsx.IsFile(*path) { + if !fsx.IsRegular(*path) { return errors.Errorf("%q does not exist or is not a file", *path) } return nil diff --git a/internal/dis/component/auth/user.go b/internal/dis/component/auth/user.go index 435f169..f337b15 100644 --- a/internal/dis/component/auth/user.go +++ b/internal/dis/component/auth/user.go @@ -1,6 +1,7 @@ package auth import ( + "bytes" "context" "encoding/base64" "fmt" @@ -14,7 +15,6 @@ import ( "github.com/pquerna/otp" "github.com/pquerna/otp/totp" "github.com/tkw1536/pkglib/password" - "github.com/tkw1536/pkglib/pools" "github.com/tkw1536/pkglib/reflectx" "golang.org/x/crypto/bcrypt" ) @@ -187,10 +187,9 @@ func TOTPLink(secret *otp.Key, width, height int) (string, error) { } // encode image as base64 - buffer := pools.GetBuffer() - defer pools.ReleaseBuffer(buffer) + var buffer bytes.Buffer - if err := png.Encode(buffer, img); err != nil { + if err := png.Encode(&buffer, img); err != nil { return "", err } diff --git a/internal/dis/component/backup.go b/internal/dis/component/backup.go index 9d58e59..42f86e3 100644 --- a/internal/dis/component/backup.go +++ b/internal/dis/component/backup.go @@ -6,8 +6,8 @@ import ( "path/filepath" "github.com/FAU-CDI/wisski-distillery/internal/models" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/pkg/errors" + "github.com/tkw1536/pkglib/fsx/umaskfree" ) // Backupable represents a component with a Backup method @@ -122,7 +122,7 @@ func (sc *stagingContext) AddDirectory(path string, op func(context.Context) err } // run the make directory - if err := fsx.Mkdir(dst, fsx.DefaultDirPerm); err != nil { + if err := umaskfree.Mkdir(dst, umaskfree.DefaultDirPerm); err != nil { return err } @@ -143,7 +143,7 @@ func (sc *stagingContext) CopyFile(dst, src string) error { return err } sc.sendPath(dst) - return fsx.CopyFile(sc.ctx, dstPath, src) + return umaskfree.CopyFile(sc.ctx, dstPath, src) } func (sc *stagingContext) CopyDirectory(dst, src string) error { @@ -156,7 +156,7 @@ func (sc *stagingContext) CopyDirectory(dst, src string) error { return err } - return fsx.CopyDirectory(sc.ctx, dstPath, src, func(dst, src string) { + return umaskfree.CopyDirectory(sc.ctx, dstPath, src, func(dst, src string) { sc.sendPath(dst) }) } @@ -174,7 +174,7 @@ func (sc *stagingContext) AddFile(path string, op func(ctx context.Context, file } // create the file - file, err := fsx.Create(dst, fsx.DefaultFilePerm) + file, err := umaskfree.Create(dst, umaskfree.DefaultFilePerm) if err != nil { return err } diff --git a/internal/dis/component/exporter/backup.go b/internal/dis/component/exporter/backup.go index 03dfd27..d817926 100644 --- a/internal/dis/component/exporter/backup.go +++ b/internal/dis/component/exporter/backup.go @@ -10,8 +10,8 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/wisski" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/logging" + "github.com/tkw1536/pkglib/fsx/umaskfree" "github.com/tkw1536/pkglib/status" "golang.org/x/exp/slices" ) @@ -118,7 +118,7 @@ func (backup *Backup) run(ctx context.Context, progress io.Writer, exporter *Exp defer st.Stop() instancesBackupDir := filepath.Join(backup.Description.Dest, "instances") - if err := fsx.Mkdir(instancesBackupDir, fsx.DefaultDirPerm); err != nil { + if err := umaskfree.Mkdir(instancesBackupDir, umaskfree.DefaultDirPerm); err != nil { backup.InstanceListErr = err return nil } @@ -139,7 +139,7 @@ func (backup *Backup) run(ctx context.Context, progress io.Writer, exporter *Exp Handler: func(instance *wisski.WissKI, index int, writer io.Writer) Snapshot { dir := filepath.Join(instancesBackupDir, instance.Slug) - if err := fsx.Mkdir(dir, fsx.DefaultDirPerm); err != nil { + if err := umaskfree.Mkdir(dir, umaskfree.DefaultDirPerm); err != nil { return Snapshot{ ErrPanic: err, } diff --git a/internal/dis/component/exporter/exporter.go b/internal/dis/component/exporter/exporter.go index 260ae0b..e7c2fa1 100644 --- a/internal/dis/component/exporter/exporter.go +++ b/internal/dis/component/exporter/exporter.go @@ -13,7 +13,8 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/dis/component/instances" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql" "github.com/FAU-CDI/wisski-distillery/internal/passwordx" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" + "github.com/tkw1536/pkglib/fsx" + "github.com/tkw1536/pkglib/fsx/umaskfree" "github.com/tkw1536/pkglib/password" ) @@ -75,7 +76,7 @@ func (*Exporter) newSnapshotName(prefix string) string { func (dis *Exporter) NewStagingDir(prefix string) (path string, err error) { for path == "" || errors.Is(err, fs.ErrExist) { path = filepath.Join(dis.StagingPath(), dis.newSnapshotName(prefix)) - err = fsx.Mkdir(path, fsx.DefaultFilePerm) + err = umaskfree.Mkdir(path, umaskfree.DefaultFilePerm) } if err != nil { path = "" diff --git a/internal/dis/component/exporter/iface.go b/internal/dis/component/exporter/iface.go index 36e5765..7fad153 100644 --- a/internal/dis/component/exporter/iface.go +++ b/internal/dis/component/exporter/iface.go @@ -12,10 +12,10 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/wisski" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/logging" "github.com/FAU-CDI/wisski-distillery/pkg/targz" "github.com/tkw1536/pkglib/collection" + "github.com/tkw1536/pkglib/fsx/umaskfree" "github.com/tkw1536/pkglib/status" ) @@ -98,7 +98,7 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta // create the staging directory logging.LogMessage(progress, "Creating staging directory") - err = fsx.Mkdir(stagingDir, fsx.DefaultDirPerm) + err = umaskfree.Mkdir(stagingDir, umaskfree.DefaultDirPerm) if !errors.Is(err, fs.ErrExist) && err != nil { return err } @@ -136,7 +136,7 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta reportPath := filepath.Join(stagingDir, ReportMachinePath) fmt.Fprintln(progress, reportPath) - report, err := fsx.Create(reportPath, fsx.DefaultFilePerm) + report, err := umaskfree.Create(reportPath, umaskfree.DefaultFilePerm) if err != nil { return err } @@ -151,7 +151,7 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta reportPath := filepath.Join(stagingDir, ReportPlainPath) fmt.Fprintln(progress, reportPath) - report, err := fsx.Create(reportPath, fsx.DefaultFilePerm) + report, err := umaskfree.Create(reportPath, umaskfree.DefaultFilePerm) if err != nil { return err } diff --git a/internal/dis/component/exporter/report.go b/internal/dis/component/exporter/report.go index d77c9fd..2b44d75 100644 --- a/internal/dis/component/exporter/report.go +++ b/internal/dis/component/exporter/report.go @@ -4,16 +4,15 @@ import ( "encoding/json" "fmt" "io" + "strings" - "github.com/tkw1536/pkglib/pools" "github.com/tkw1536/pkglib/sequence" ) func (snapshot Snapshot) String() string { - builder := pools.GetBuilder() - defer pools.ReleaseBuilder(builder) + var builder strings.Builder - snapshot.ReportPlain(builder) + snapshot.ReportPlain(&builder) return builder.String() } @@ -68,10 +67,8 @@ func (snapshot Snapshot) ReportPlain(w io.Writer) error { // Strings turns this backup into a string for the BackupReport. func (backup Backup) String() string { - builder := pools.GetBuilder() - defer pools.ReleaseBuilder(builder) - - backup.ReportPlain(builder) + var builder strings.Builder + backup.ReportPlain(&builder) return builder.String() } diff --git a/internal/dis/component/provision/provision.go b/internal/dis/component/provision/provision.go index 231866a..4cba7a9 100644 --- a/internal/dis/component/provision/provision.go +++ b/internal/dis/component/provision/provision.go @@ -8,8 +8,8 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/instances" "github.com/FAU-CDI/wisski-distillery/internal/wisski" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/logging" + "github.com/tkw1536/pkglib/fsx" ) type Provision struct { diff --git a/internal/dis/component/server/home/public.go b/internal/dis/component/server/home/public.go index 8fef9fc..beb3dd9 100644 --- a/internal/dis/component/server/home/public.go +++ b/internal/dis/component/server/home/public.go @@ -11,7 +11,6 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/templating" "github.com/FAU-CDI/wisski-distillery/internal/status" "github.com/tkw1536/pkglib/httpx" - "github.com/tkw1536/pkglib/pools" ) //go:embed "public.html" @@ -62,8 +61,7 @@ func (home *Home) publicHandler(ctx context.Context) http.Handler { } // get a builder - builder := pools.GetBuilder() - defer pools.ReleaseBuilder(builder) + var builder strings.Builder // prepare about pc.aboutContext.Logo = logoHTML @@ -72,7 +70,7 @@ func (home *Home) publicHandler(ctx context.Context) http.Handler { // render the about template - if err := about.Execute(builder, pc.aboutContext); err != nil { + if err := about.Execute(&builder, pc.aboutContext); err != nil { return pc, nil } diff --git a/internal/dis/component/server/news/news.go b/internal/dis/component/server/news/news.go index af375e7..4eaa7cb 100644 --- a/internal/dis/component/server/news/news.go +++ b/internal/dis/component/server/news/news.go @@ -13,7 +13,6 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/assets" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/templating" "github.com/rs/zerolog" - "github.com/tkw1536/pkglib/pools" "github.com/yuin/goldmark" gmmeta "github.com/yuin/goldmark-meta" "github.com/yuin/goldmark/parser" @@ -90,8 +89,7 @@ var newsFS embed.FS // Items returns a list of all news items func Items() ([]Item, error) { - builder := pools.GetBuilder() - defer pools.ReleaseBuilder(builder) + var builder strings.Builder files, err := fs.Glob(newsFS, "NEWS/*.md") if err != nil { @@ -101,7 +99,7 @@ func Items() ([]Item, error) { items := make([]Item, len(files)) for i, file := range files { items[i].ID = file[len("NEWS/") : len(file)-len(".md")] - if err := items[i].parse(file, builder); err != nil { + if err := items[i].parse(file, &builder); err != nil { return nil, err } } diff --git a/internal/dis/component/server/templating/base.go b/internal/dis/component/server/templating/base.go index 1d21fcf..f646cd9 100644 --- a/internal/dis/component/server/templating/base.go +++ b/internal/dis/component/server/templating/base.go @@ -8,12 +8,12 @@ import ( "html/template" "net/http" "reflect" + "strings" "time" "github.com/gorilla/csrf" "github.com/rs/zerolog" "github.com/tkw1536/pkglib/httpx" - "github.com/tkw1536/pkglib/pools" "github.com/tkw1536/pkglib/timex" ) @@ -251,9 +251,7 @@ func (ctx *tContext[C]) renderSafe(name string, t *template.Template, c any) (te } value, err, panicked := func() (value template.HTML, err error, panicked bool) { - // get a builder - builder := pools.GetBuilder() - defer pools.ReleaseBuilder(builder) + var builder strings.Builder defer func() { if panicked { @@ -267,7 +265,7 @@ func (ctx *tContext[C]) renderSafe(name string, t *template.Template, c any) (te }() panicked = true - err = t.Execute(builder, c) + err = t.Execute(&builder, c) panicked = false if err != nil { diff --git a/internal/dis/component/sql/sql.go b/internal/dis/component/sql/sql.go index b5c6779..5faf080 100644 --- a/internal/dis/component/sql/sql.go +++ b/internal/dis/component/sql/sql.go @@ -6,7 +6,7 @@ import ( "time" "github.com/FAU-CDI/wisski-distillery/internal/dis/component" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" + "github.com/tkw1536/pkglib/fsx/umaskfree" ) type SQL struct { @@ -50,7 +50,7 @@ func (sql *SQL) Stack() component.StackWithResources { "HTTPS_ENABLED": sql.Config.HTTP.HTTPSEnabledEnv(), }, - MakeDirsPerm: fsx.DefaultDirPerm, + MakeDirsPerm: umaskfree.DefaultDirPerm, MakeDirs: []string{ "data", "imports", diff --git a/internal/dis/component/ssh2/server_hostkeys.go b/internal/dis/component/ssh2/server_hostkeys.go index 458e564..8b9296e 100644 --- a/internal/dis/component/ssh2/server_hostkeys.go +++ b/internal/dis/component/ssh2/server_hostkeys.go @@ -12,8 +12,8 @@ import ( "io/fs" "os" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/gliderlabs/ssh" + "github.com/tkw1536/pkglib/fsx/umaskfree" "github.com/pkg/errors" gossh "golang.org/x/crypto/ssh" @@ -120,7 +120,7 @@ func (ssh2 *SSH2) makeHostKey(progress io.Writer, ctx context.Context, key HostK } // generate and write private key as PEM - privateKeyFile, err := fsx.Create(path, fsx.DefaultFilePerm) + privateKeyFile, err := umaskfree.Create(path, umaskfree.DefaultFilePerm) if err != nil { return err } diff --git a/internal/dis/component/stack.go b/internal/dis/component/stack.go index c6bc0b1..c58fd8a 100644 --- a/internal/dis/component/stack.go +++ b/internal/dis/component/stack.go @@ -11,9 +11,9 @@ import ( "github.com/FAU-CDI/wisski-distillery/pkg/compose" "github.com/FAU-CDI/wisski-distillery/pkg/execx" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/FAU-CDI/wisski-distillery/pkg/unpack" "github.com/pkg/errors" + "github.com/tkw1536/pkglib/fsx/umaskfree" "github.com/tkw1536/pkglib/stream" ) @@ -193,7 +193,7 @@ func (is StackWithResources) Install(ctx context.Context, progress io.Writer, co return err } } else { - if err := fsx.MkdirAll(is.Dir, fsx.DefaultDirPerm); err != nil { + if err := umaskfree.MkdirAll(is.Dir, umaskfree.DefaultDirPerm); err != nil { return err } } @@ -206,7 +206,7 @@ func (is StackWithResources) Install(ctx context.Context, progress io.Writer, co defer fmt.Fprintf(progress, "[install] %s\n", dst) // create the file - yml, err := fsx.Create(dst, fsx.DefaultFilePerm) + yml, err := umaskfree.Create(dst, umaskfree.DefaultFilePerm) if err != nil { return err } @@ -253,9 +253,9 @@ func (is StackWithResources) Install(ctx context.Context, progress io.Writer, co fmt.Fprintf(progress, "[make] %s\n", dst) if is.MakeDirsPerm == fs.FileMode(0) { - is.MakeDirsPerm = fsx.DefaultDirPerm + is.MakeDirsPerm = umaskfree.DefaultDirPerm } - if err := fsx.MkdirAll(dst, is.MakeDirsPerm); err != nil { + if err := umaskfree.MkdirAll(dst, is.MakeDirsPerm); err != nil { return err } } @@ -273,7 +273,7 @@ func (is StackWithResources) Install(ctx context.Context, progress io.Writer, co // copy over file from context fmt.Fprintf(progress, "[copy] %s (from %s)\n", dst, src) - if err := fsx.CopyFile(ctx, dst, src); err != nil { + if err := umaskfree.CopyFile(ctx, dst, src); err != nil { return errors.Wrapf(err, "Unable to copy file %s", src) } } @@ -284,7 +284,7 @@ func (is StackWithResources) Install(ctx context.Context, progress io.Writer, co dst := filepath.Join(is.Dir, name) fmt.Fprintf(progress, "[touch] %s\n", dst) - if err := fsx.Touch(dst, is.TouchFilesPerm); err != nil { + if err := umaskfree.Touch(dst, is.TouchFilesPerm); err != nil { return err } } diff --git a/internal/dis/component/triplestore/database.go b/internal/dis/component/triplestore/database.go index 641032b..c3ea200 100644 --- a/internal/dis/component/triplestore/database.go +++ b/internal/dis/component/triplestore/database.go @@ -11,7 +11,6 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog" - "github.com/tkw1536/pkglib/pools" "github.com/tkw1536/pkglib/timex" ) @@ -39,12 +38,10 @@ func (ts Triplestore) OpenRaw(ctx context.Context, method, url string, body any, // for "PUT" and "POST" we setup a body if method == http.MethodPut || method == http.MethodPost { if bodyName != "" { - // create a new buffer for the body - buffer := pools.GetBuffer() - defer pools.ReleaseBuffer(buffer) + var buffer bytes.Buffer // write the file to it - writer := multipart.NewWriter(buffer) + writer := multipart.NewWriter(&buffer) { part, err := writer.CreateFormFile(bodyName, "filename.txt") if err != nil { @@ -55,7 +52,7 @@ func (ts Triplestore) OpenRaw(ctx context.Context, method, url string, body any, writer.Close() // use it for the request - reader = buffer + reader = &buffer contentType = writer.FormDataContentType() } else { mbytes, err := json.Marshal(body) diff --git a/internal/dis/component/triplestore/provision.go b/internal/dis/component/triplestore/provision.go index 404b5ff..75046d1 100644 --- a/internal/dis/component/triplestore/provision.go +++ b/internal/dis/component/triplestore/provision.go @@ -11,7 +11,6 @@ import ( "github.com/FAU-CDI/wisski-distillery/pkg/unpack" "github.com/tkw1536/goprogram/exit" "github.com/tkw1536/pkglib/errorx" - "github.com/tkw1536/pkglib/pools" ) var errTripleStoreFailedRepository = exit.Error{ @@ -39,9 +38,9 @@ func (ts *Triplestore) CreateRepository(ctx context.Context, name, domain, user, } // prepare the create repo request - createRepo := pools.GetBuffer() - defer pools.ReleaseBuffer(createRepo) - err := unpack.WriteTemplate(createRepo, map[string]string{ + var createRepo bytes.Buffer + + err := unpack.WriteTemplate(&createRepo, map[string]string{ "GRAPHDB_REPO": name, "INSTANCE_DOMAIN": domain, }, bytes.NewReader(createRepoTTL)) diff --git a/internal/status/wisski_user.go b/internal/status/wisski_user.go index 22136f8..44df6f8 100644 --- a/internal/status/wisski_user.go +++ b/internal/status/wisski_user.go @@ -7,7 +7,6 @@ import ( "time" "github.com/FAU-CDI/wisski-distillery/internal/phpx" - "github.com/tkw1536/pkglib/pools" "golang.org/x/exp/slices" ) @@ -25,20 +24,19 @@ type DrupalUser struct { } func (du DrupalUser) String() string { - builder := pools.GetBuilder() - defer pools.ReleaseBuilder(builder) + var builder strings.Builder builder.WriteString("DrupalUser{") defer builder.WriteString("}") - fmt.Fprintf(builder, "UID: %d, ", du.UID) - fmt.Fprintf(builder, "Name: %q, ", du.Name) + fmt.Fprintf(&builder, "UID: %d, ", du.UID) + fmt.Fprintf(&builder, "Name: %q, ", du.Name) if du.Mail != "" { - fmt.Fprintf(builder, "Mail: %q, ", du.Mail) + fmt.Fprintf(&builder, "Mail: %q, ", du.Mail) } - fmt.Fprintf(builder, "Status: %t, ", du.Status) + fmt.Fprintf(&builder, "Status: %t, ", du.Status) for _, tn := range []struct { Name string @@ -52,10 +50,10 @@ func (du DrupalUser) String() string { if tn.Time.IsZero() { continue } - fmt.Fprintf(builder, "%s: %q, ", tn.Name, tn.Time.Format(time.Stamp)) + fmt.Fprintf(&builder, "%s: %q, ", tn.Name, tn.Time.Format(time.Stamp)) } - fmt.Fprintf(builder, "Roles: %s", du.Roles) + fmt.Fprintf(&builder, "Roles: %s", du.Roles) return builder.String() } diff --git a/internal/wisski/ingredient/php/extras/prefixes.go b/internal/wisski/ingredient/php/extras/prefixes.go index 8bb451c..67bd92b 100644 --- a/internal/wisski/ingredient/php/extras/prefixes.go +++ b/internal/wisski/ingredient/php/extras/prefixes.go @@ -12,8 +12,8 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/mstore" "github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/tkw1536/pkglib/collection" + "github.com/tkw1536/pkglib/fsx" "golang.org/x/exp/slices" _ "embed" @@ -35,7 +35,7 @@ var ( // NoPrefix checks if this WissKI instance is excluded from generating prefixes. // TODO: Move this to the database! func (prefixes *Prefixes) NoPrefix() bool { - return fsx.IsFile(filepath.Join(prefixes.FilesystemBase, "prefixes.skip")) + return fsx.IsRegular(filepath.Join(prefixes.FilesystemBase, "prefixes.skip")) } //go:embed prefixes.php @@ -121,7 +121,7 @@ func hasAnyPrefix(candidate string, prefixes []string) bool { func (wisski *Prefixes) filePrefixes() (prefixes []string, err error) { path := filepath.Join(wisski.FilesystemBase, "prefixes") - if !fsx.IsFile(path) { + if !fsx.IsRegular(path) { return nil, nil } diff --git a/pkg/fsx/copy.go b/pkg/fsx/copy.go deleted file mode 100644 index ee9c7c4..0000000 --- a/pkg/fsx/copy.go +++ /dev/null @@ -1,150 +0,0 @@ -package fsx - -import ( - "context" - "errors" - "io/fs" - "os" - "path/filepath" - - "github.com/tkw1536/pkglib/contextx" -) - -var ErrCopySameFile = errors.New("src and dst must be different") - -// CopyFile copies a file from src to dst. -// When src points to a symbolic link, will copy the symbolic link. -// -// When dst and src are the same file, returns [ErrCopySameFile]. -// When ctx is closed, the file is not copied. -func CopyFile(ctx context.Context, dst, src string) error { - if err := ctx.Err(); err != nil { - return err - } - - if SameFile(src, dst) { - return ErrCopySameFile - } - - // open the source - srcFile, err := os.Open(src) - if err != nil { - return err - } - defer srcFile.Close() - - // stat it to get the mode! - srcStat, err := srcFile.Stat() - if err != nil { - return err - } - - // open or create the destination - dstFile, err := Create(dst, srcStat.Mode()) - if err != nil { - return err - } - defer dstFile.Close() - - // and do the copy! - _, err = contextx.Copy(ctx, dstFile, srcFile) - return err -} - -// CopyLink copies a link from src to dst. -// If dst already exists, it is deleted and then re-created. -func CopyLink(ctx context.Context, dst, src string) error { - if err := ctx.Err(); err != nil { - return err - } - - // if they're the same file that is an error - if SameFile(dst, src) { - return ErrCopySameFile - } - - // read the link target - target, err := os.Readlink(src) - if err != nil { - return err - } - - // delete it if it already exists - if Exists(dst) { - if err := os.Remove(dst); err != nil { - return err - } - } - - // make the symbolic link! - return os.Symlink(target, dst) -} - -var ErrDstFile = errors.New("dst is a file") - -// CopyDirectory copies the directory src to dst recursively. -// Copying is aborted when ctx is closed. -// -// Existing files and directories are overwritten. -// When a directory already exists, additional files are not deleted. -// -// onCopy, when not nil, is called for each file or directory being copied. -func CopyDirectory(ctx context.Context, dst, src string, onCopy func(dst, src string)) error { - // sanity checks - if SameFile(src, dst) { - return ErrCopySameFile - } - if IsFile(dst) { - return ErrDstFile - } - - return filepath.WalkDir(src, func(path string, d fs.DirEntry, err error) error { - // someone previously returned an error - if err != nil { - return err - } - - // context was closed - if err := ctx.Err(); err != nil { - return err - } - - // determine the real target path - var relpath string - relpath, err = filepath.Rel(src, path) - if err != nil { - return err - } - dst := filepath.Join(dst, relpath) - - // call the hook - if onCopy != nil { - onCopy(dst, src) - } - - // stat the directory, so that we can get mode, and info later! - info, err := d.Info() - if err != nil { - return err - } - - // if we have a symbolic link, copy the link! - if info.Mode()&fs.ModeSymlink != 0 { - return CopyLink(ctx, dst, path) - } - - // if we got a file, we should copy it normally - if !d.IsDir() { - return CopyFile(ctx, dst, path) - } - - // create the directory, but ignore an error if the directory already exists. - // this is so that we can copy one tree into another tree. - err = Mkdir(dst, info.Mode()) - if errors.Is(err, fs.ErrExist) && IsDirectory(dst) { - err = nil - } - - return err - }) -} diff --git a/pkg/fsx/create.go b/pkg/fsx/create.go deleted file mode 100644 index c8d2a14..0000000 --- a/pkg/fsx/create.go +++ /dev/null @@ -1,57 +0,0 @@ -package fsx - -import ( - "errors" - "io/fs" - "os" - "time" -) - -// Create is like [os.Create] with an additional mode argument. -func Create(path string, mode fs.FileMode) (*os.File, error) { - m.Lock() - defer m.Unlock() - - return os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode) -} - -// WriteFile is like [os.WriteFile]. -func WriteFile(path string, data []byte, mode fs.FileMode) error { - handle, err := Create(path, mode) - if err != nil { - return err - } - defer handle.Close() - - if _, err := handle.Write(data); err != nil { - return err - } - - return nil -} - -// Touch touches a file. -// It is similar to the unix 'touch' command. -// -// If the file does not exist, it is created using [Create]. -// If the file does exist, its' access and modification times are updated to the current time. -func Touch(path string, perm fs.FileMode) error { - if perm == 0 { - perm = DefaultFilePerm - } - _, err := os.Stat(path) - switch { - case errors.Is(err, fs.ErrNotExist): - f, err := Create(path, perm) - if err != nil { - return err - } - defer f.Close() - return nil - case err != nil: - return err - default: - now := time.Now().Local() - return os.Chtimes(path, now, now) - } -} diff --git a/pkg/fsx/dir.go b/pkg/fsx/dir.go deleted file mode 100644 index 412ad4b..0000000 --- a/pkg/fsx/dir.go +++ /dev/null @@ -1,25 +0,0 @@ -package fsx - -import ( - "io/fs" - "os" -) - -// DefaultDirPerm should be used by callers to use a consistent mode for new directories. -const DefaultDirPerm fs.FileMode = fs.ModeDir | fs.ModePerm - -// Mkdir is like [os.Mkdir]. -func Mkdir(path string, mode fs.FileMode) error { - m.Lock() - defer m.Unlock() - - return os.Mkdir(path, fs.ModeDir|mode) -} - -// MkdirAll is like [os.MkdirAll]. -func MkdirAll(path string, mode fs.FileMode) error { - m.Lock() - defer m.Unlock() - - return os.MkdirAll(path, fs.ModeDir|mode) -} diff --git a/pkg/fsx/fsx.go b/pkg/fsx/fsx.go deleted file mode 100644 index 6b0cf14..0000000 --- a/pkg/fsx/fsx.go +++ /dev/null @@ -1,37 +0,0 @@ -// Package fsx provides additional file system functionality. -// -// All functions in this package ignore the umask. -// As such it is not safe to use otherwise equivalent functions provided by the standard go library concurrently with this package. -// Users should take care that no other code in their application uses these functions. -package fsx - -import ( - "io/fs" - "sync" - "syscall" -) - -// DefaultFilePerm should be used by callers to use a consistent file mode for new files. -const DefaultFilePerm fs.FileMode = 0666 - -// mask is the global mask lock -var m mask - -// mask allows disabling and re-enabling the global umask. -// it is used by allow functions of this package. -type mask struct { - l sync.Mutex // locked? - umask int // previous mask -} - -// Lock blocks until no other function is using this umask -// and then sets it to 0. -func (mask *mask) Lock() { - mask.l.Lock() - mask.umask = syscall.Umask(0) -} - -func (mask *mask) Unlock() { - mask.umask = syscall.Umask(mask.umask) - mask.l.Unlock() -} diff --git a/pkg/fsx/same.go b/pkg/fsx/same.go deleted file mode 100644 index c0df9d6..0000000 --- a/pkg/fsx/same.go +++ /dev/null @@ -1,89 +0,0 @@ -package fsx - -import ( - "errors" - "io/fs" - "os" - "path/filepath" -) - -// SameFile checks if path1 and path2 refer to the same file. -// If both files exist, they are compared using [os.SameFile]. -// If both files do not exist, the paths are first compared syntactically and then via recursion on [filepath.Dir]. -func SameFile(path1, path2 string) bool { - - // initial attempt: check if directly - same, certain := couldBeSameFile(path1, path2) - if certain { - return same - } - - // second attempt: find the directory names and base paths - d1, n1 := filepath.Dir(path1), filepath.Base(path1) - d2, n2 := filepath.Dir(path2), filepath.Base(path2) - - // if we have different file names (and they don't exist) - // we don't need to continue - if n1 != n2 { - return false - } - - // compare the base names! - { - same, _ := couldBeSameFile(d1, d2) - return same - } -} - -// couldBeSameFile checks if path1 might be the same as path2. -// -// If both files exist, compares using [os.SameFile]. -// Otherwise compares absolute paths using string comparison. -// -// same indicates if they might be the same file. -// authorative indiciates if the result is authorative. -func couldBeSameFile(path1, path2 string) (same, authorative bool) { - { - // stat both files - info1, err1 := os.Stat(path1) - info2, err2 := os.Stat(path2) - - // both files exist => check using env.SameFile - // the result is always authorative - if err1 == nil && err2 == nil { - same = os.SameFile(info1, info2) - authorative = true - return - } - - // only 1 file errored => they could be different - if (err1 == nil) != (err2 == nil) { - return - } - - // only 1 file does not exist => they could be different - if errors.Is(err1, fs.ErrNotExist) != errors.Is(err2, fs.ErrNotExist) { - return - } - } - - { - // resolve paths absolutely - rpath1, err1 := filepath.Abs(path1) - rpath2, err2 := filepath.Abs(path2) - - // if either path could not be resolved absolutely - // fallback to just using clean! - if err1 != nil { - rpath1 = filepath.Clean(path1) - } - if err2 != nil { - rpath2 = filepath.Clean(path2) - } - - // compare using strings - same = rpath1 == rpath2 - authorative = same // positive result is authorative! - return - } -} diff --git a/pkg/fsx/type.go b/pkg/fsx/type.go deleted file mode 100644 index 34d7445..0000000 --- a/pkg/fsx/type.go +++ /dev/null @@ -1,31 +0,0 @@ -// Package fsx provides convenient abstractions to work with the filesystem. -package fsx - -import ( - "io/fs" - "os" -) - -// Exists checks if the given path exists -func Exists(path string) bool { - _, err := os.Lstat(path) - return err == nil -} - -// IsDirectory checks if the provided path exists and is a directory -func IsDirectory(path string) bool { - info, err := os.Stat(path) - return err == nil && info.Mode().IsDir() -} - -// IsFile checks if the provided path exists and is a regular file -func IsFile(path string) bool { - info, err := os.Stat(path) - return err == nil && info.Mode().IsRegular() -} - -// IsLink checks if the provided path exists and is a symlink -func IsLink(path string) bool { - info, err := os.Lstat(path) - return err == nil && info.Mode()&fs.ModeSymlink != 0 -} diff --git a/pkg/targz/targz.go b/pkg/targz/targz.go index 5f45d82..ea561b7 100644 --- a/pkg/targz/targz.go +++ b/pkg/targz/targz.go @@ -9,7 +9,7 @@ import ( "os" "path/filepath" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" + "github.com/tkw1536/pkglib/fsx/umaskfree" ) // Package packages the source directory into a 'tar.gz' file into destination. @@ -18,7 +18,7 @@ import ( // onCopy, when not nil, is called for each file being copied into the archive. func Package(dst, src string, onCopy func(rel string, src string)) (count int64, err error) { // create the target archive - archive, err := fsx.Create(dst, fsx.DefaultFilePerm) + archive, err := umaskfree.Create(dst, umaskfree.DefaultFilePerm) if err != nil { return 0, err } diff --git a/pkg/unpack/resource.go b/pkg/unpack/resource.go index 304b654..89f7fd8 100644 --- a/pkg/unpack/resource.go +++ b/pkg/unpack/resource.go @@ -6,8 +6,8 @@ import ( "os" "path/filepath" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" "github.com/pkg/errors" + "github.com/tkw1536/pkglib/fsx/umaskfree" ) var errExpectedFileButGotDirectory = errors.New("expected a file, but got a directory") @@ -84,7 +84,7 @@ func installDir(dst string, srcInfo fs.FileInfo, srcFile fs.ReadDirFile, src str dstStat, dstErr := os.Stat(dst) switch { case errors.Is(dstErr, fs.ErrNotExist): - if err := fsx.MkdirAll(dst, srcInfo.Mode()); err != nil { + if err := umaskfree.MkdirAll(dst, srcInfo.Mode()); err != nil { return errors.Wrapf(err, "Error creating destination directory %s", dst) } case dstErr != nil: @@ -120,7 +120,7 @@ func installDir(dst string, srcInfo fs.FileInfo, srcFile fs.ReadDirFile, src str func installFile(dst string, srcInfo fs.FileInfo, src fs.File) error { // create the file using the right mode! - file, err := fsx.Create(dst, srcInfo.Mode()) + file, err := umaskfree.Create(dst, srcInfo.Mode()) if err != nil { return err } diff --git a/pkg/unpack/template.go b/pkg/unpack/template.go index 999225b..4af64c7 100644 --- a/pkg/unpack/template.go +++ b/pkg/unpack/template.go @@ -8,7 +8,7 @@ import ( "io/fs" "strings" - "github.com/FAU-CDI/wisski-distillery/pkg/fsx" + "github.com/tkw1536/pkglib/fsx/umaskfree" "golang.org/x/exp/maps" "golang.org/x/exp/slices" ) @@ -222,7 +222,7 @@ func InstallTemplate(dst string, context map[string]string, src string, fsys fs. } // open the destination file - file, err := fsx.Create(dst, srcInfo.Mode()) + file, err := umaskfree.Create(dst, srcInfo.Mode()) if err != nil { return err }