Skip to content

Commit c8a37a2

Browse files
anobakaclaude
andcommitted
fix: allow DataPath at install root so the beta.69~74 recovery works
Mirrors the submodule change: the InsideInstall validation now refuses only current/ and packages/, not the entire install root. Adds three tests pinning the new behavior (current/ refused, packages/ refused, install root and its siblings allowed) and updates the user-facing error message in cn / en to match. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 63f0a73 commit c8a37a2

4 files changed

Lines changed: 50 additions & 3 deletions

File tree

src/tests/Bakabase.Tests/DataPathValidatorTests.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public void Validate_CurrentIsAncestorOfTarget_Refused()
9292
[TestMethod]
9393
public void Validate_InsideVelopackInstall_Refused()
9494
{
95+
// Inside current/ — atomically replaced on upgrade, must be refused.
9596
var installRoot = Path.Combine(_root, "Bakabase-install");
9697
var target = Path.Combine(installRoot, "current", "AppData");
9798
var current = Path.Combine(_root, "elsewhere");
@@ -102,6 +103,52 @@ public void Validate_InsideVelopackInstall_Refused()
102103
Assert.AreEqual(DataPathValidator.RefusalReason.InsideInstall, result.Reason);
103104
}
104105

106+
[TestMethod]
107+
public void Validate_InsideVelopackPackages_Refused()
108+
{
109+
// packages/ holds Velopack download cache — pruned on upgrade, must be refused.
110+
var installRoot = Path.Combine(_root, "Bakabase-install");
111+
var target = Path.Combine(installRoot, "packages", "data");
112+
var current = Path.Combine(_root, "elsewhere");
113+
Directory.CreateDirectory(current);
114+
var input = MakeInput(target, current, installRoot: installRoot);
115+
var result = DataPathValidator.Validate(input);
116+
Assert.IsFalse(result.Valid);
117+
Assert.AreEqual(DataPathValidator.RefusalReason.InsideInstall, result.Reason);
118+
}
119+
120+
[TestMethod]
121+
public void Validate_TargetEqualsInstallRoot_Allowed()
122+
{
123+
// Install root itself — survives upgrade (Velopack only swaps current/), so it is
124+
// not refused. This is the recovery target for users coming from 2.3.0-beta.69~74
125+
// whose default DataPath physically lived at the install root. The orthogonal
126+
// uninstall / Repair risk is surfaced via AppInfo.DataInInstallRoot.
127+
var installRoot = Path.Combine(_root, "Bakabase-install");
128+
Directory.CreateDirectory(installRoot);
129+
var current = Path.Combine(_root, "elsewhere");
130+
Directory.CreateDirectory(current);
131+
var input = MakeInput(installRoot, current, installRoot: installRoot);
132+
var result = DataPathValidator.Validate(input);
133+
Assert.IsTrue(result.Valid, $"Expected valid, got {result.Reason}");
134+
}
135+
136+
[TestMethod]
137+
public void Validate_InstallRootSiblingDir_Allowed()
138+
{
139+
// A non-Velopack-managed dir under the install root (e.g. user-stored data
140+
// folder at the install root level) is also safe from upgrade and must be
141+
// allowed.
142+
var installRoot = Path.Combine(_root, "Bakabase-install");
143+
var target = Path.Combine(installRoot, "my-data");
144+
Directory.CreateDirectory(target);
145+
var current = Path.Combine(_root, "elsewhere");
146+
Directory.CreateDirectory(current);
147+
var input = MakeInput(target, current, installRoot: installRoot);
148+
var result = DataPathValidator.Validate(input);
149+
Assert.IsTrue(result.Valid, $"Expected valid, got {result.Reason}");
150+
}
151+
105152
[TestMethod]
106153
public void Validate_SystemPath_Windows_Refused()
107154
{

src/web/src/locales/cn/pages/configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"configuration.dataPath.validation.relativePath": "请使用绝对路径。",
7575
"configuration.dataPath.validation.invalidChars": "路径含有非法字符。",
7676
"configuration.dataPath.validation.sameAsCurrent": "目标路径与当前路径相同。",
77-
"configuration.dataPath.validation.insideInstall": "不能选择安装目录内部,从 2.3 版本开始升级时会清空旧的安装目录,放在里面的数据会丢失。",
77+
"configuration.dataPath.validation.insideInstall": "不能选择安装目录中的 current/ 或 packages/ 子目录——这些目录由 Velopack 管理,会在升级时被替换或清理,放在里面的数据会丢失。",
7878
"configuration.dataPath.validation.circularContainment": "目标路径与当前路径互相包含。",
7979
"configuration.dataPath.validation.systemPath": "不能使用系统目录。",
8080
"configuration.dataPath.validation.noWritePermission": "目标路径没有写入权限。",

src/web/src/locales/en/pages/configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"configuration.dataPath.validation.relativePath": "Use an absolute path.",
7575
"configuration.dataPath.validation.invalidChars": "Path contains invalid characters.",
7676
"configuration.dataPath.validation.sameAsCurrent": "Target equals the current path.",
77-
"configuration.dataPath.validation.insideInstall": "Cannot place data inside the install directory — starting with 2.3 the previous install directory is wiped on upgrade and any data inside is lost.",
77+
"configuration.dataPath.validation.insideInstall": "Cannot place data inside the install directory's current/ or packages/ subfolders — these are managed by Velopack and replaced or pruned on upgrade; any data inside would be lost.",
7878
"configuration.dataPath.validation.circularContainment": "Target and current path contain each other.",
7979
"configuration.dataPath.validation.systemPath": "System directories are not allowed.",
8080
"configuration.dataPath.validation.noWritePermission": "No write permission for the target.",

0 commit comments

Comments
 (0)