Skip to content

Commit

Permalink
APP-7377 registry modules on windows (#4702)
Browse files Browse the repository at this point in the history
  • Loading branch information
abe-winter authored Jan 14, 2025
1 parent 0ddadcc commit 1c994c8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions robot/packages/cloud_package_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"net/url"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -238,6 +239,9 @@ func (m *cloudManager) validateAndGetChangedPackages(

// Cleanup removes all unknown packages from the working directory.
func (m *cloudManager) Cleanup(ctx context.Context) error {
if runtime.GOOS == "windows" { //nolint:goconst
return nil
}
// Only allow one rdk process to operate on the manager at once. This is generally safe to keep locked for an extended period of time
// since the config reconfiguration process is handled by a single thread.
m.mu.Lock()
Expand Down
17 changes: 16 additions & 1 deletion robot/packages/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"io/fs"
"os"
"path/filepath"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -85,7 +86,16 @@ func installPackage(
return err
}

err = os.Rename(tmpDataPath, p.LocalDataDirectory(packagesDir))
renameDest := p.LocalDataDirectory(packagesDir)
if runtime.GOOS == "windows" {
if _, err := os.Stat(renameDest); err == nil {
logger.Debug("package rename destination exists, deleting")
if err := os.RemoveAll(renameDest); err != nil {
logger.Warnf("ignoring error from removing rename dest %s", err)
}
}
}
err = os.Rename(tmpDataPath, renameDest)
if err != nil {
utils.UncheckedError(cleanup(packagesDir, p))
return err
Expand Down Expand Up @@ -381,6 +391,11 @@ func readStatusFile(pkg config.PackageConfig, packagesDir string) (packageSyncFi

func writeStatusFile(pkg config.PackageConfig, statusFile packageSyncFile, packagesDir string) error {
syncFileName := getSyncFileName(pkg.LocalDataDirectory(packagesDir))
if runtime.GOOS == "windows" {
if err := os.MkdirAll(pkg.LocalDataDirectory(packagesDir), os.ModeDir); err != nil {
return err
}
}

statusFileBytes, err := json.MarshalIndent(statusFile, "", " ")
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion robot/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ import (

// SubtypeName is a constant that identifies the internal web resource subtype string.
const (
SubtypeName = "web"
SubtypeName = "web"
// TCPParentPort is the port of the parent socket when VIAM_TCP_MODE is set.
TCPParentPort = 14998
// TestTCPParentPort is the test suite version of TCPParentPort. It's different to avoid
// collisions; it's listed here for documentation.
Expand Down
6 changes: 6 additions & 0 deletions utils/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ func PlatformHomeDir() string {
if runtime.GOOS == "android" {
return AndroidFilesDir
}
if runtime.GOOS == "windows" {
homedir, _ := os.UserHomeDir() //nolint:errcheck
if homedir != "" {
return homedir
}
}
return os.Getenv("HOME")
}

Expand Down

0 comments on commit 1c994c8

Please sign in to comment.