Skip to content

Commit

Permalink
fix(proxy): use and define arity to set transparent input (#172)
Browse files Browse the repository at this point in the history
fix(proxy): change action on model to include CPU/dry-run (#172)

fix(proxy): define and use arity to set transparent input (#172)
  • Loading branch information
plastikfan committed Feb 20, 2024
1 parent be71771 commit 01e40bf
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 110 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"plog",
"prealloc",
"promptui",
"randemoji",
"repotoken",
"samber",
"sidewalk",
Expand Down
18 changes: 15 additions & 3 deletions src/app/proxy/enter-shrink.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (e *ShrinkEntry) run() (result *nav.TraverseResult, err error) {
e.PrincipalOptionsFn,
runnerWith,
resumption,
e.Inputs.Root.PreviewFam.Native.DryRun,
e.Inputs,
))

return result, err
Expand All @@ -169,13 +169,25 @@ func EnterShrink(
err error
)

schemes := params.Inputs.Root.Configs.Schemes
selectedScheme := params.Inputs.Root.ProfileFam.Native.Scheme
scheme, _ := schemes.Scheme(selectedScheme)
noProfiles := lo.TernaryF(scheme == nil,
func() uint {
return 1
},
func() uint {
return uint(len(scheme.Profiles()))
},
)
finder := filing.NewFinder(&filing.NewFinderInfo{
Advanced: params.Inputs.Root.Configs.Advanced,
Schemes: params.Inputs.Root.Configs.Schemes,
Scheme: params.Inputs.Root.ProfileFam.Native.Scheme,
Schemes: schemes,
Scheme: selectedScheme,
OutputPath: params.Inputs.ParamSet.Native.OutputPath,
TrashPath: params.Inputs.ParamSet.Native.TrashPath,
Observer: params.Inputs.Root.Observers.PathFinder,
Arity: noProfiles,
})
fileManager := filing.NewManager(params.Vfs, finder,
params.Inputs.Root.PreviewFam.Native.DryRun,
Expand Down
2 changes: 1 addition & 1 deletion src/app/proxy/filing/file-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (fm *FileManager) Finder() common.PathFinder {

func (fm *FileManager) Create(path string, overwrite bool) error {
if fm.Vfs.FileExists(path) && !overwrite {
return os.ErrExist
return errors.Wrapf(os.ErrExist, "could not create file at path: '%v'", path)
}

file, err := fm.Vfs.Create(path)
Expand Down
3 changes: 2 additions & 1 deletion src/app/proxy/filing/path-finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type NewFinderInfo struct {
OutputPath string
TrashPath string
Observer common.PathFinder
Arity uint
}

func NewFinder(
Expand Down Expand Up @@ -179,7 +180,7 @@ func (f *PathFinder) init(info *NewFinderInfo) {
// When the user specifies an alternative location for the results to be sent to
// with the --output flag, then the input is no longer transparent, as the user has
// to go to the output location to see the result.
f.transparentInput = info.OutputPath == ""
f.transparentInput = info.OutputPath == "" && info.Arity == 1

journal := info.Advanced.JournalLabel()

Expand Down
Loading

0 comments on commit 01e40bf

Please sign in to comment.