Major changes:
- Refactor server startup to run cache, events, and cron in background goroutines
- Main thread only handles server lifecycle and shutdown coordination
- Add proper error handling with os.Exit(1) instead of hanging lg.Fatal()
Database connection improvements:
- Add connect_timeout parameter to PostgreSQL DSN (10s default)
- Wrap gorm.Open in goroutine with timeout context for cancellable connections
- Improve retry logging with attempt counters and clear error messages
- Check context cancellation during retry delays
Event system:
- Add EventBroadcaster interface with Redis and Polling implementations
- Base broadcaster with DB worker pool, deduplication, and graceful drain
- Redis broadcaster for multi-instance setups with Pub/Sub
- Polling broadcaster for single-instance setups
- Configurable: DBWorkers, DBBufferSize, DeduplicationTTL
Other improvements:
- Add distributed locking for channel creation (PostgreSQL advisory locks)
- Fix KV storage upsert with ON CONFLICT
- Ensure process exits immediately on fatal errors
Implements BLAKE3 cryptographic hashing to provide file integrity verification
and support for future deduplication features.
Key features:
- Tree hashing: Files are hashed in 16MB blocks, with block hashes stored
concatenated in uploads table, then tree-hashed for final file hash
- BlockHasher: Streaming hasher that processes data in fixed-size blocks
during upload without loading entire file into memory
- Fast verification: BLAKE3 is significantly faster than MD5/SHA256 while
maintaining cryptographic security
Database changes:
- Added block_hashes (BYTEA) column to teldrive.uploads table for storing
per-block hashes during upload process
- Added hash (TEXT) column to teldrive.files table for final tree hash
- Migration: 20260201144943_add_hash_column.sql
Code changes:
- New package: internal/hash/hash.go with BlockHasher implementation
- Updated models: File.Hash and Upload.BlockHashes fields
- Upload service: Computes block hashes during file upload when hashing enabled
- File service: Computes final tree hash from block hashes after upload complete
The hashing is designed to support:
- File integrity verification on download
- Deduplication across users (same file = same hash)
- Efficient verification of large files without full re-download
Note: Hash computation is optional and controlled by client 'hashing' parameter
- Implement channel rollover based on part count limits
- Auto-create channels and add bots as admins
- Add teldrive.kv key-value table
- Deduplicate bots and set (user_id, token) as primary key
- Introduced a new configuration option `locker-instance` for distributed cron job locking.
- Updated the cron job service to use `gormlock` for distributed locking.
- Refactored the `StartCronJobs` function to initialize the locker and scheduler.
- Added new cron jobs for cleaning old events and logging actions for existing jobs.
* feat: Add Stream Bots Offset flag to run command
* feat: Update Stream Bots Offset flag in run command
* update
* update
* update
* invalidate cache on update
* chore: Update cache key for file location deletion
* chore: Update cache key for file location retrieval
* chore: Refactor file service to optimize token processing
* chore: Optimize token processing in file service
* chore: Update file service to use PUT method for updating parts