Files
2025-12-29 17:16:35 +01:00

3.3 KiB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

CloudBackup is a Rust application for managing cloud storage backups, specifically designed to work with S3-compatible storage services (including DigitalOcean Spaces). The application reads cloud storage configurations from config.json and provides utilities for listing and managing bucket contents.

Common Commands

Build and Run

cargo build          # Build the project
cargo run            # Run the application
cargo build --release  # Build optimized release binary

Development

cargo check          # Quick compilation check without binary
cargo clippy         # Run linter
cargo fmt            # Format code

Testing

cargo test           # Run all tests
cargo test <test_name>  # Run specific test

Architecture

Module Structure

The codebase follows a standard Rust module organization:

  • src/main.rs: Entry point that loads cloud configurations from config.json and iterates through each cloud storage to list bucket contents
  • src/models/: Data models for the application
    • cloud.rs: Defines CloudS3 struct representing S3-compatible cloud storage configuration (name, region, bucket, credentials, endpoint URL)
  • src/utils/: Utility functions
    • s3_utils.rs: Core S3 operations including bucket listing with folder/file distinction, uses AWS SDK for S3

Key Components

CloudS3 Configuration Model (src/models/cloud.rs:4-11):

  • Deserializes from JSON configuration
  • Contains all necessary S3 connection parameters including custom endpoint URLs for S3-compatible services

S3Item Struct (src/utils/s3_utils.rs:7-12):

  • Represents bucket items (files or folders)
  • Contains key, type (folder/file), size, and last modified timestamp
  • Custom Display implementation for Hungarian language output

S3 Operations (src/utils/s3_utils.rs):

  • list_bucket(): Async function that connects to S3-compatible storage and retrieves bucket contents with optional prefix filtering
  • Uses delimiter="/" to distinguish between folders (common_prefixes) and files (contents)
  • Configures AWS SDK with custom credentials and endpoint URLs
  • print_bucket_contents(): Convenience wrapper that lists and prints bucket contents

Configuration

The application uses config.json which contains an array of cloud storage configurations. Each configuration includes:

  • name: Identifier for the storage
  • region: AWS region (or equivalent for S3-compatible services)
  • bucket: Bucket name
  • accesskey/secretekey: Credentials
  • endpoint_url: Custom endpoint for S3-compatible services like DigitalOcean Spaces

Note: The config.json file contains credentials and should never be committed to version control.

Dependencies

  • AWS SDK: aws-sdk-s3 and aws-config for S3 operations with custom endpoint support
  • Serde: JSON serialization/deserialization for configuration
  • Tokio: Async runtime for handling S3 API calls

Code Conventions

  • The codebase includes Hungarian language comments and user-facing messages
  • Debug output is verbose in S3 utilities to aid in troubleshooting connection issues
  • Error handling uses Result types with descriptive error messages