Teldrive Documentation

repository·main·Indexed 25 days ago

https://github.com/tgdrive/teldrive

A high-performance utility written in Go that acts as a wrapper for Telegram accounts to organize and manage files. Teldrive provides an interface compatible with Rclone and includes a CLI for running the service, verifying file integrity via the check command, and managing updates.

Tokens
1.4K
Snippets
2
Records
11
Agent score
84%

What's inside Teldrive

  1. Overview of Teldrive

    main
    Teldrive is a utility designed to organize Telegram files. It acts as a wrapper over your Telegram account to simplify file access and provides an intuitive user interface for file interaction. It is compatible with Rclone, allowing for enhanced file management capabilities.
  2. Important Usage Warnings and Best Practices

    main

    Telegram API Compliance

    Teldrive is a wrapper over your Telegram account. You must strictly adhere to the limitations imposed by the Telegram API. Misusing the Telegram API can result in an instant account ban. Teldrive is not responsible for consequences arising from non-compliance with these limits.

    Best Practices

    To avoid account bans or automatic deletion of your channels/files, follow these guidelines:

    Dos:

    • Follow Limits: Adhere to all limits imposed by Telegram servers.
    • Responsible Storage: Use storage efficiently and only keep data that serves a purpose.

    Don'ts:

    • Data Hoarding: Avoid excessive data hoarding, as it violates Telegram's terms of service.
  3. Use the `check` command to verify file integrity

    main

    The check command verifies the integrity of files stored in Telegram channels by comparing database records with actual Telegram messages. It identifies missing file parts, orphan messages, and incomplete uploads.

    Key Capabilities:

    • Dry-run: Preview issues without making any changes to the database or Telegram.
    • Export: Save a list of missing files to a JSON file.
    • Cleanup: Remove missing files, orphan messages, pending files, and incomplete uploads from the database and Telegram.
    • Concurrency: Process multiple channels simultaneously to speed up the check.
    # Preview issues without making changes (dry-run)
    teldrive check --user alice --dry-run
    
    # Check, clean and export missing files to a custom file
    teldrive check --export-file missing_files.json
    
    # Clean missing and pending files along with incompleted uploads
    teldrive check --clean-pending --clean-uploads
    
    # Concurrent processing
    teldrive check --concurrent 8
  4. Available Teldrive subcommands

    main

    The Teldrive CLI supports the following subcommands:

    • run: Starts the Teldrive service.
    • check: Performs system or configuration checks.
    • update: Updates the Teldrive installation.
    • version: Displays the current version of Teldrive.
  5. Configure Teldrive Server via CLI flags

    main

    The run command accepts configuration flags defined by the config.ServerCmdConfig struct. These flags allow you to customize the server's behavior, including database connections, Redis settings, logging, and server timeouts.

    Common configuration areas include:

    • Server: Port, Read/Write timeouts, and Graceful Shutdown duration.
    • Log: Log level (e.g., info, debug, error) and file path.
    • DB: Database connection details and logging settings.
    • Redis: Connection settings for the cache and bot selector.
    • Events: Poll interval, worker counts, and buffer sizes.
    • JWT: Settings for JSON Web Token authentication.
    • CronJobs: Toggle for background cron jobs via cron-jobs.enable.
  6. Configure the `check` command flags

    main

    The check command uses several flags to control the verification and cleanup process. These flags are part of the config.CheckCmdConfig structure.

    FlagDescription
    --userSpecify the username to run the check for. If omitted, you will be prompted to select a user from the available list.
    --dry-runIf set, the command will only report issues and will not delete any files, messages, or database records.
    --export-file <path>Specifies the path to a JSON file where missing files will be exported (only works when not in --dry-run mode).
    --clean-pendingWhen set, deletes files from the database that have a status of pending_deletion.
    --clean-uploadsWhen set, deletes incomplete upload records from the database.
    --concurrent <int>Sets the number of channels to process concurrently.
    --db-data-source <string>Required. The data source for the database connection.
  7. Upgrade TelDrive using the upgrade command

    main

    Use the upgrade command to update TelDrive to the latest version. The command automatically detects your operating system and executes the appropriate installation script.

    • Windows: Uses powershell to run the update script.
    • Linux/macOS (darwin): Uses bash to run the update script.

    Note: On Windows, you must manually restart TelDrive after the upgrade process completes to use the new version. On Unix-like systems, the command will attempt to verify the version automatically.

  8. Start the Teldrive Server with the `run` command

    main

    The run command is the primary CLI entrypoint used to start the Teldrive service. When executed, it initializes the database, connects to Redis, starts the event broadcaster, and launches the HTTP server (providing both the API and the Web UI).

    If the configured port is already in use, the application will attempt to find an available port within a range of 100 ports starting from the configured value. If a different port is used, the server will log the server.port_occupied event with the occupied_port and new_port details.