Skip to content

Commit 2a2d4d7

Browse files
committed
Move hard link detection into constructor so it's only done once.
1 parent fdcf750 commit 2a2d4d7

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

pkg/runtime/setup.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ type Opts struct {
6262
type SetOpt func(*Opts)
6363

6464
type setup struct {
65-
path string
66-
opts *Opts
67-
depot *depot
68-
env *envdef.Collection
69-
buildplan *buildplan.BuildPlan
65+
path string
66+
opts *Opts
67+
depot *depot
68+
supportsHardLinks bool
69+
env *envdef.Collection
70+
buildplan *buildplan.BuildPlan
7071

7172
// toBuild encompasses all artifacts that will need to be build for this runtime.
7273
// This does NOT mean every artifact in the runtime closure if this is an update (as oppose to a fresh toInstall).
@@ -163,16 +164,17 @@ func newSetup(path string, bp *buildplan.BuildPlan, env *envdef.Collection, depo
163164
}
164165

165166
return &setup{
166-
path: path,
167-
opts: opts,
168-
env: env,
169-
depot: depot,
170-
buildplan: bp,
171-
toBuild: artifactsToBuild.ToIDMap(),
172-
toDownload: artifactsToDownload.ToIDMap(),
173-
toUnpack: artifactsToUnpack.ToIDMap(),
174-
toInstall: artifactsToInstall.ToIDMap(),
175-
toUninstall: artifactsToUninstall,
167+
path: path,
168+
opts: opts,
169+
env: env,
170+
depot: depot,
171+
supportsHardLinks: supportsHardLinks(depot.depotPath),
172+
buildplan: bp,
173+
toBuild: artifactsToBuild.ToIDMap(),
174+
toDownload: artifactsToDownload.ToIDMap(),
175+
toUnpack: artifactsToUnpack.ToIDMap(),
176+
toInstall: artifactsToInstall.ToIDMap(),
177+
toUninstall: artifactsToUninstall,
176178
}, nil
177179
}
178180

@@ -470,7 +472,7 @@ func (s *setup) install(id strfmt.UUID) (rerr error) {
470472
if err := envDef.ApplyFileTransforms(s.path); err != nil {
471473
return errs.Wrap(err, "Could not apply env transforms")
472474
}
473-
} else if supportsHardLinks(s.depot.depotPath) {
475+
} else if s.supportsHardLinks {
474476
if err := s.depot.DeployViaLink(id, envDef.InstallDir, s.path); err != nil {
475477
return errs.Wrap(err, "Could not deploy artifact via link")
476478
}

0 commit comments

Comments
 (0)