Skip to content

Commit 03f30b1

Browse files
committed
Setup is responsible for knowing if the depot supports hard links or not, and acts accordingly.
1 parent 84273fa commit 03f30b1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

pkg/runtime/depot.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type depot struct {
5555
depotPath string
5656
artifacts map[strfmt.UUID]struct{}
5757
fsMutex *sync.Mutex
58-
supportsHardLinks bool
58+
SupportsHardLinks bool
5959
}
6060

6161
func newDepot(runtimePath string) (*depot, error) {
@@ -78,7 +78,7 @@ func newDepot(runtimePath string) (*depot, error) {
7878
depotPath: depotPath,
7979
artifacts: map[strfmt.UUID]struct{}{},
8080
fsMutex: &sync.Mutex{},
81-
supportsHardLinks: supportsHardLinks(depotPath),
81+
SupportsHardLinks: supportsHardLinks(depotPath),
8282
}
8383

8484
if !fileutils.TargetExists(depotPath) {
@@ -148,8 +148,8 @@ func (d *depot) Put(id strfmt.UUID) error {
148148

149149
// DeployViaLink will take an artifact from the depot and link it to the target path.
150150
func (d *depot) DeployViaLink(id strfmt.UUID, relativeSrc, absoluteDest string) error {
151-
if !d.supportsHardLinks {
152-
return d.DeployViaCopy(id, relativeSrc, absoluteDest)
151+
if !d.SupportsHardLinks {
152+
return errs.New("depot does not support hard links; use copy instead")
153153
}
154154

155155
d.fsMutex.Lock()

pkg/runtime/setup.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,14 @@ func (s *setup) install(id strfmt.UUID) (rerr error) {
470470
if err := envDef.ApplyFileTransforms(s.path); err != nil {
471471
return errs.Wrap(err, "Could not apply env transforms")
472472
}
473-
} else {
473+
} else if s.depot.SupportsHardLinks {
474474
if err := s.depot.DeployViaLink(id, envDef.InstallDir, s.path); err != nil {
475475
return errs.Wrap(err, "Could not deploy artifact via link")
476476
}
477+
} else {
478+
if err := s.depot.DeployViaCopy(id, envDef.InstallDir, s.path); err != nil {
479+
return errs.Wrap(err, "Could not deploy artifact via copy")
480+
}
477481
}
478482

479483
return nil

0 commit comments

Comments
 (0)