fix: 按系统规范解析桌面服务数据目录

macOS 和 Windows 在未显式指定工作目录时,通过 Go 的用户配置目录接口解析 YdisksXianyuHelper 数据目录;macOS LaunchAgent 不再注入数据库、密钥和浏览器目录参数。

服务自动创建数据目录及 data 子目录,将默认 SQLite 数据库放置到系统用户数据目录,修复 macOS 服务因 data/xianyu_data.db 父目录不存在而启动即退出的问题。

保留显式工作目录、Windows 现有 ProgramData 数据布局以及 Linux/Docker 的默认相对路径行为,并补充服务目录解析和数据库路径测试。

删除名称为桌面端 CI 的 GitHub Actions Workflow,保留桌面安装包构建发布 Workflow。
This commit is contained in:
Christ committed 2026-08-12 00:19:14 +08:00
1 parent bfa72fd9b7
commit d4e9717570
5 files changed
+94 -98

No files matched your search

+37
View File
@@ -54,3 +54,40 @@ func TestLoadOrCreateDataKeyPersists(t *testing.T) {
t.Fatalf("data key file was not written: err=%v", err)
}
}
func TestResolveDataDirKeepsExplicitDirectory(t *testing.T) {
explicit := filepath.Join(t.TempDir(), "ydisks-data")
got, err := resolveDataDir(explicit)
if err != nil {
t.Fatalf("resolve explicit data directory: %v", err)
}
if got != explicit {
t.Fatalf("explicit data directory changed: got %q want %q", got, explicit)
}
}
func TestUserDataDirName(t *testing.T) {
base := filepath.Join(t.TempDir(), "Application Support")
got := filepath.Join(base, userDataDirName)
want := filepath.Join(base, "YdisksXianyuHelper")
if got != want {
t.Fatalf("unexpected user data directory: got %q want %q", got, want)
}
}
func TestResolveDBPathUsesDataDirectoryForDefault(t *testing.T) {
dataDir := filepath.Join(t.TempDir(), "YdisksXianyuHelper")
got := resolveDBPath(dataDir, defaultDBPath)
want := filepath.Join(dataDir, "data", "xianyu_data.db")
if got != want {
t.Fatalf("unexpected default database path: got %q want %q", got, want)
}
}
func TestResolveDBPathPreservesCustomPath(t *testing.T) {
dataDir := filepath.Join(t.TempDir(), "YdisksXianyuHelper")
custom := filepath.Join(t.TempDir(), "custom.db")
if got := resolveDBPath(dataDir, custom); got != custom {
t.Fatalf("custom database path changed: got %q want %q", got, custom)
}
}