library: winget's record folder is compared with its links followed, as the rtk path is (#6127)

askWingetOwns follows the links of the rtk path it is given, but compared
it with winget's recorded install folder as written. A folder reached
through a link or a junction (macOS's /var is /private/var; a junction
over a Windows profile folder) never matched, so an rtk winget installed
read as not winget's and got no "winget upgrade" upgrader.
TestRTKWindowsRelease's "recorded" step was red on mote for that reason;
its own expected path was also the link, not the file it leads to.

Now the record's folder is tried with its links followed too, and the
test expects the followed path.

Run, at this head (origin/main 961427f12 base):
- go test -count=1 -timeout 30m ./internal/library: ok on mote (macOS),
  ok on WSL magpie-desktop.
- Windows (xiaomi-gpu, win-run), whole package: three reds,
  TestGoneAgentListedToTakeOut, TestCheckMixedServerEachSide and
  TestPluginImportCarryOnOffRemove. All three fail the same way alone at
  origin/main 961427f12 on that box; filed in #6065 and #4115.
- Broken by hand: without the askWingetOwns change, -run 'TestRTK|Winget'
  is red on mote at "recorded: upgrader ... want winget upgrade".
Not tried: a real winget install behind a junction.
This commit is contained in:
yetone
2026-11-11 17:21:00 +08:00
parent 961427f122
commit a1961f5ca1
2 changed files with 14 additions and 2 deletions
+6
View File
@@ -704,6 +704,12 @@ func askWingetOwns(bin, real string) (yes, known bool) {
if inFolder(real, l) || inFolder(bin, l) {
return true, true
}
// real has its links followed, so the record's folder is too:
// a folder reached through a link or junction (macOS's /var is
// /private/var) is the same folder
if lr, err := filepath.EvalSymlinks(l); err == nil && lr != l && inFolder(real, lr) {
return true, true
}
}
return false, true
}
+8 -2
View File
@@ -319,8 +319,14 @@ func TestRTKWingetFolderWithoutRecord(t *testing.T) {
// winget has records, none of them this folder
wingetOn(t, h, wingetUnlisted, 0, func() ([]string, bool) { return []string{filepath.Join(h, "elsewhere")}, true })
if c := rtkUpgrader(link); len(c) != 2 || c[0] != rtkWindowsRelease || c[1] != real {
t.Fatalf("no record: upgrader %q; want %s %s", c, rtkWindowsRelease, real)
// the link is followed to its file, and macOS's temp folder is itself a
// link (/var to /private/var)
want, err := filepath.EvalSymlinks(real)
if err != nil {
t.Fatal(err)
}
if c := rtkUpgrader(link); len(c) != 2 || c[0] != rtkWindowsRelease || c[1] != want {
t.Fatalf("no record: upgrader %q; want %s %s", c, rtkWindowsRelease, want)
}
v, err := UpgradeRTK()
if err != nil || v.Version != "0.51.0" {