fsx: Remove environment references

This commit removes the reference to the environment from the fsx
package.
This commit is contained in:
Tom Wiesing 2023-03-02 11:47:11 +01:00
parent 5a43ecfaeb
commit 3263920d6b
No known key found for this signature in database
25 changed files with 167 additions and 183 deletions

View file

@ -10,7 +10,7 @@ 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/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
"github.com/tkw1536/goprogram/status"
"golang.org/x/exp/slices"
@ -119,7 +119,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 := exporter.Environment.Mkdir(instancesBackupDir, environment.DefaultDirPerm); err != nil {
if err := fsx.Mkdir(instancesBackupDir, fsx.DefaultDirPerm); err != nil {
backup.InstanceListErr = err
return nil
}
@ -140,7 +140,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 := exporter.Environment.Mkdir(dir, environment.DefaultDirPerm); err != nil {
if err := fsx.Mkdir(dir, fsx.DefaultDirPerm); err != nil {
return Snapshot{
ErrPanic: err,
}

View file

@ -12,7 +12,6 @@ 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/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/tkw1536/pkglib/password"
)
@ -51,7 +50,7 @@ func (dis *Exporter) ArchivePath() string {
// The path is guaranteed to not exist.
func (dis *Exporter) NewArchivePath(prefix string) (path string) {
// TODO: Consider moving these into a subdirectory with the provided prefix.
for path == "" || fsx.Exists(dis.Environment, path) {
for path == "" || fsx.Exists(path) {
name := dis.newSnapshotName(prefix) + ".tar.gz"
path = filepath.Join(dis.ArchivePath(), name)
}
@ -75,7 +74,7 @@ func (*Exporter) newSnapshotName(prefix string) string {
func (dis *Exporter) NewStagingDir(prefix string) (path string, err error) {
for path == "" || os.IsExist(err) {
path = filepath.Join(dis.StagingPath(), dis.newSnapshotName(prefix))
err = dis.Still.Environment.Mkdir(path, environment.DefaultFilePerm)
err = fsx.Mkdir(path, fsx.DefaultFilePerm)
}
if err != nil {
path = ""

View file

@ -8,7 +8,7 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
"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/goprogram/status"
@ -74,7 +74,7 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta
// create the staging directory
logging.LogMessage(progress, ctx, "Creating staging directory")
err = exporter.Environment.Mkdir(stagingDir, environment.DefaultDirPerm)
err = fsx.Mkdir(stagingDir, fsx.DefaultDirPerm)
if !os.IsExist(err) && err != nil {
return err
}
@ -112,7 +112,7 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta
logging.ProgressF(progress, ctx, reportPath)
// create the path
report, err := exporter.Environment.Create(reportPath, environment.DefaultFilePerm)
report, err := fsx.Create(reportPath, fsx.DefaultFilePerm)
if err != nil {
return err
}