Skip to content

Create fileManager for Temporary Project Setup [backend] #26

@salazarsebas

Description

@salazarsebas

📁 Create fileManager for Temporary Project Setup 🗄

📝 Description

Develop a fileManager utility to create and clean up temporary Rust projects for compilation and testing. This utility will generate a Cargo.toml and src/lib.rs in a temporary directory, ensuring each request is isolated. It will also handle cleanup to prevent disk space issues. This modular approach enhances maintainability and supports secure execution by isolating user code.

🎯 Objective

Create a TypeScript utility in apps/backend/src/utils/ to manage temporary Rust project directories and files.

🗂 Structure

  • Directory: apps/backend/src/utils/
  • Files:
    • apps/backend/src/utils/fileManager.ts
  • Expected structure:
    apps/backend/
    ├── src/
    │   ├── utils/
    │   │   └── fileManager.ts
    

✅ Requirements

  • Create fileManager.ts with two functions:
    • setupProject(tempDir: string, code: string): Promise<void>: Creates a Rust project with Cargo.toml and src/lib.rs.
    • cleanupProject(tempDir: string): Promise<void>: Deletes the temporary directory.
  • Use fs.promises for asynchronous file operations.
  • Include a default Cargo.toml with soroban-sdk = "21.2.0".
  • Ensure tempDir is unique (e.g., temp/project_${Date.now()}).
  • Test file creation and cleanup with a sample directory.
  • Commit changes with a message like feat: create file manager utility.
  • Push changes to the GitHub repository.

🏆 Expected Outcomes

  • fileManager creates temporary Rust projects with correct Cargo.toml and src/lib.rs.
  • Cleanup function deletes directories without errors.
  • Utility is reusable and handles errors gracefully.
  • Changes are committed and pushed to GitHub.

🔗 References

📋 Notes

  • Use sanitize-filename (from a later issue) for safe directory names.
  • Ensure cleanup is idempotent to handle partial failures.

Metadata

Metadata

Assignees

Labels

backendIssues for the development of the backend of the online soroban compilerenhancementNew feature or requestexpressjsIssues related to the application backend and the Express js framework

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions