Skip to content

Commit

Permalink
Use volume-specific depot for Windows runtimes not on the main volume.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-as committed Aug 1, 2024
1 parent 1d66f33 commit d1ce45d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/runtime/depot.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ type depot struct {
fsMutex *sync.Mutex
}

func newDepot() (*depot, error) {
func newDepot(volume string) (*depot, error) {
depotPath := filepath.Join(storage.CachePath(), depotName)
if volume != "" { // Windows volume label for this depot
depotPath = filepath.Join(volume+"\\", "activestate", depotName)
}

result := &depot{
config: depotConfig{
Expand Down
12 changes: 11 additions & 1 deletion pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/fileutils"
"github.com/ActiveState/cli/internal/installation/storage"
"github.com/ActiveState/cli/internal/logging"
"github.com/ActiveState/cli/pkg/buildplan"
"github.com/ActiveState/cli/pkg/runtime/internal/envdef"
Expand Down Expand Up @@ -46,7 +47,16 @@ func New(path string) (*Runtime, error) {
return nil, errs.Wrap(err, "Could not create runtime directory")
}

depot, err := newDepot()
// Windows does not support hard-linking across drives, so determine if the runtime path is on a
// separate drive than the default depot path. If so, use a drive-specific depot path when
// initializing the depot.
runtimeVolume := filepath.VolumeName(path)
storageVolume := filepath.VolumeName(storage.CachePath())
if runtimeVolume == storageVolume {
runtimeVolume = ""
}

depot, err := newDepot(runtimeVolume)
if err != nil {
return nil, errs.Wrap(err, "Could not create depot")
}
Expand Down

0 comments on commit d1ce45d

Please sign in to comment.