Refactor: migrate POSIX scaffolding to CBOR and JSONC
This commit is contained in:
@@ -57,11 +57,11 @@ func (service *Service) createProjectFolderOnDisk(projectSlug, parentFolderID, n
|
||||
return "", "", fmt.Errorf("create project hierarchy folder: %w", err)
|
||||
}
|
||||
folderID := uuid.NewString()
|
||||
if err := writeJSONFile(filepath.Join(folderDir, "folder.json"), map[string]any{"id": folderID, "name": trimmedName, "slug": folderSlug, "type": "folder"}); err != nil {
|
||||
return "", "", fmt.Errorf("write project folder.json: %w", err)
|
||||
if err := writeCBORFile(filepath.Join(folderDir, posixFolderFileName), map[string]any{"id": folderID, "name": trimmedName, "slug": folderSlug, "type": "folder"}); err != nil {
|
||||
return "", "", fmt.Errorf("write project %s: %w", posixFolderFileName, err)
|
||||
}
|
||||
if err := writeJSONFile(filepath.Join(folderDir, "acl.json"), map[string]any{"version": 1, "inherits": true, "rules": []any{}}); err != nil {
|
||||
return "", "", fmt.Errorf("write project acl.json: %w", err)
|
||||
if err := writeCBORFile(filepath.Join(folderDir, posixACLFileName), map[string]any{"version": 1, "inherits": true, "rules": []any{}}); err != nil {
|
||||
return "", "", fmt.Errorf("write project %s: %w", posixACLFileName, err)
|
||||
}
|
||||
return filepath.ToSlash(filepath.Join(containerProjectionPath, folderName)), folderSlug, nil
|
||||
}
|
||||
@@ -150,13 +150,13 @@ func (service *Service) renameProjectFolderOnDisk(projectSlug, folderID, name st
|
||||
return "", "", fmt.Errorf("rename project folder: %w", err)
|
||||
}
|
||||
}
|
||||
folderPayload := readJSONFileMap(filepath.Join(destinationDir, "folder.json"))
|
||||
folderPayload := readStructuredFileMap(filepath.Join(destinationDir, posixFolderFileName))
|
||||
folderMetadataID, _ := folderPayload["id"].(string)
|
||||
if strings.TrimSpace(folderMetadataID) == "" {
|
||||
folderMetadataID = uuid.NewString()
|
||||
}
|
||||
if err := writeJSONFile(filepath.Join(destinationDir, "folder.json"), map[string]any{"id": folderMetadataID, "name": trimmedName, "slug": folderSlug, "type": "folder"}); err != nil {
|
||||
return "", "", fmt.Errorf("write renamed project folder.json: %w", err)
|
||||
if err := writeCBORFile(filepath.Join(destinationDir, posixFolderFileName), map[string]any{"id": folderMetadataID, "name": trimmedName, "slug": folderSlug, "type": "folder"}); err != nil {
|
||||
return "", "", fmt.Errorf("write renamed project %s: %w", posixFolderFileName, err)
|
||||
}
|
||||
return folderProjectionPath, renamedProjectionPath, nil
|
||||
}
|
||||
@@ -210,7 +210,7 @@ func (service *Service) moveProjectFolderOnDisk(projectSlug, folderID, parentFol
|
||||
if samePath(currentParentDir, parentDir) {
|
||||
return folderProjectionPath, folderProjectionPath, nil
|
||||
}
|
||||
folderPayload := readJSONFileMap(filepath.Join(folderDir, "folder.json"))
|
||||
folderPayload := readStructuredFileMap(filepath.Join(folderDir, posixFolderFileName))
|
||||
folderMetadataID, _ := folderPayload["id"].(string)
|
||||
if strings.TrimSpace(folderMetadataID) == "" {
|
||||
folderMetadataID = uuid.NewString()
|
||||
@@ -244,8 +244,8 @@ func (service *Service) moveProjectFolderOnDisk(projectSlug, folderID, parentFol
|
||||
folderPayload["name"] = folderName
|
||||
folderPayload["slug"] = folderSlug
|
||||
folderPayload["type"] = "folder"
|
||||
if err := writeJSONFile(filepath.Join(destinationDir, "folder.json"), folderPayload); err != nil {
|
||||
return "", "", fmt.Errorf("write moved project folder.json: %w", err)
|
||||
if err := writeCBORFile(filepath.Join(destinationDir, posixFolderFileName), folderPayload); err != nil {
|
||||
return "", "", fmt.Errorf("write moved project %s: %w", posixFolderFileName, err)
|
||||
}
|
||||
movedProjectionPath := filepath.ToSlash(filepath.Join(parentChildrenProjectionPath, folderDirName))
|
||||
return folderProjectionPath, movedProjectionPath, nil
|
||||
|
||||
Reference in New Issue
Block a user