Fix: scaffold bootstrap personal folder

This commit is contained in:
MangoPig
2026-06-24 19:46:02 +01:00
parent 4fb073a1ff
commit eadf630c61
2 changed files with 62 additions and 0 deletions
+39
View File
@@ -1304,6 +1304,12 @@ func (service *Service) ensureBootstrapPOSIXSkeleton(
teamPath := filepath.Join(departmentPath, "teams", slugDir("team", team.Slug))
projectPath := filepath.Join(rootPath, "projects", slugDir("project", project.Slug))
usersPath := filepath.Join(rootPath, "users")
personalName := strings.TrimSpace(admin.DisplayName)
if personalName == "" {
personalName = defaultPersonalDisplayName
}
personalSlug := normalizePOSIXSlug(personalName)
personalHomePath := filepath.Join(usersPath, "personals", slugDir("personal", personalSlug))
for _, dirPath := range []string{
departmentPath,
@@ -1312,6 +1318,8 @@ func (service *Service) ensureBootstrapPOSIXSkeleton(
filepath.Join(projectPath, "children"),
filepath.Join(projectPath, "tree"),
filepath.Join(usersPath, "personals"),
personalHomePath,
filepath.Join(personalHomePath, "tree"),
} {
if err := os.MkdirAll(dirPath, 0o755); err != nil {
return fmt.Errorf("create POSIX directory %s: %w", dirPath, err)
@@ -1397,6 +1405,37 @@ func (service *Service) ensureBootstrapPOSIXSkeleton(
return fmt.Errorf("write users data.json: %w", err)
}
if err := writeJSONFile(filepath.Join(personalHomePath, "settings.json"), map[string]any{
"id": admin.ID,
"name": personalName,
"slug": personalSlug,
"type": "personal",
"ownerUserId": admin.ID,
"email": admin.Email,
}); err != nil {
return fmt.Errorf("write personal settings.json: %w", err)
}
if err := writeJSONFile(filepath.Join(personalHomePath, "layout.json"), map[string]any{
"version": 1,
"type": "personal-layout",
}); err != nil {
return fmt.Errorf("write personal layout.json: %w", err)
}
if err := writeJSONFile(filepath.Join(personalHomePath, "home.json"), map[string]any{
"type": "personal-home",
"title": personalHomeTitle(personalName),
"owner": map[string]any{
"id": admin.ID,
"email": admin.Email,
"displayName": personalName,
},
"widgets": []any{},
}); err != nil {
return fmt.Errorf("write personal home.json: %w", err)
}
return nil
}