pkg/environment: Remove some file-based functions
This commit removes certain file-based functions from 'pkg/environment', continuing the migration to entirely remove the package.
This commit is contained in:
parent
39207a1cb5
commit
45540ab253
20 changed files with 52 additions and 120 deletions
|
|
@ -3,6 +3,7 @@ package exporter
|
|||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||
|
|
@ -83,7 +84,7 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta
|
|||
if !task.StagingOnly {
|
||||
defer func() {
|
||||
logging.LogMessage(progress, ctx, "Removing staging directory")
|
||||
exporter.Environment.RemoveAll(stagingDir)
|
||||
os.RemoveAll(stagingDir)
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package logger
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql"
|
||||
|
|
@ -62,7 +63,7 @@ func (log *Logger) Log(ctx context.Context) ([]models.Export, error) {
|
|||
|
||||
// partition out the exports that have been deleted!
|
||||
parts := collection.Partition(exports, func(s models.Export) bool {
|
||||
_, err := log.Still.Environment.Stat(s.Path)
|
||||
_, err := os.Stat(s.Path)
|
||||
return !environment.IsNotExist(err)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package exporter
|
|||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ func (exporter *Exporter) PruneExports(ctx context.Context, progress io.Writer)
|
|||
sPath := exporter.ArchivePath()
|
||||
|
||||
// list all the files
|
||||
entries, err := exporter.Still.Environment.ReadDir(sPath)
|
||||
entries, err := os.ReadDir(sPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -46,7 +47,7 @@ func (exporter *Exporter) PruneExports(ctx context.Context, progress io.Writer)
|
|||
path := filepath.Join(sPath, entry.Name())
|
||||
logging.ProgressF(progress, ctx, "Removing %s cause it is older than %d days\n", path, exporter.Config.MaxBackupAge)
|
||||
|
||||
if err := exporter.Still.Environment.Remove(path); err != nil {
|
||||
if err := os.Remove(path); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue