Commit Graph

50 Commits

Author SHA1 Message Date
ARUNAVO RAY
5d2462e5a0 feat: add notification system with Ntfy.sh and Apprise support (#238)
* feat: add notification system with Ntfy.sh and Apprise providers (#231)

Add push notification support for mirror job events with two providers:

- Ntfy.sh: direct HTTP POST to ntfy topics with priority/tag support
- Apprise API: aggregator gateway supporting 100+ notification services

Includes database migration (0010), settings UI tab, test endpoint,
auto-save integration, token encryption, and comprehensive tests.
Notifications are fire-and-forget and never block the mirror flow.

* fix: address review findings for notification system

- Fix silent catch in GET handler that returned ciphertext to UI,
  causing double-encryption on next save. Now clears token to ""
  on decryption failure instead.
- Add Zod schema validation to test notification endpoint, following
  project API route pattern guidelines.
- Mark notifyOnNewRepo toggle as "coming soon" with disabled state,
  since the backend doesn't yet emit new_repo events. The schema
  and type support is in place for when it's implemented.

* fix notification gating and config validation

* trim sync notification details
2026-03-18 18:36:51 +05:30
ARUNAVO RAY
d697cb2bc9 fix: prevent starred repo name collisions during concurrent mirroring (#236)
* fix: prevent starred repo name collisions during concurrent mirroring (#95)

When multiple starred repos share the same short name (e.g. alice/dotfiles
and bob/dotfiles), concurrent batch mirroring could cause 409 Conflict
errors because generateUniqueRepoName only checked Gitea via HTTP, missing
repos that were claimed in the local DB but not yet created remotely.

Three fixes:
- Add DB-level check in generateUniqueRepoName so it queries the local
  repositories table for existing mirroredLocation claims, preventing two
  concurrent jobs from picking the same target name.
- Clear mirroredLocation on failed mirror so a failed repo doesn't falsely
  hold a location that was never successfully created, which would block
  retries and confuse the uniqueness check.
- Extract isMirroredLocationClaimedInDb helper for the DB lookup, using
  ne() to exclude the current repo's own record from the collision check.

* fix: address review findings for starred repo name collision fix

- Make generateUniqueRepoName immediately claim name by writing
  mirroredLocation to DB, closing the TOCTOU race window between
  name selection and the later status="mirroring" DB update
- Add fullName validation guard (must contain "/")
- Make isMirroredLocationClaimedInDb fail-closed (return true on
  DB error) to be conservative about preventing collisions
- Scope mirroredLocation clear on failure to starred repos only,
  preserving it for non-starred repos that may have partially
  created in Gitea and need the location for recovery

* fix: address P1/P2 review findings for starred repo name collision

P1a: Remove early name claiming from generateUniqueRepoName to prevent
stale claims on early return paths. The function now only checks
availability — the actual claim happens at the status="mirroring" DB
write (after both idempotency checks), which is protected by a new
unique partial index.

P1b: Add unique partial index on (userId, mirroredLocation) WHERE
mirroredLocation != '' via migration 0010. This enforces atomicity at
the DB level: if two concurrent workers try to claim the same name,
the second gets a constraint violation rather than silently colliding.

P2: Only clear mirroredLocation on failure if the Gitea migrate call
itself failed (migrateSucceeded flag). If migrate succeeded but
metadata mirroring failed, preserve the location since the repo
physically exists in Gitea and we need it for recovery/retry.
2026-03-18 15:27:20 +05:30
ARUNAVO RAY
e26ed3aa9c fix: rewrite migration 0009 for SQLite compatibility and add migration validation (#230)
SQLite rejects ALTER TABLE ADD COLUMN with expression defaults like
DEFAULT (unixepoch()), which Drizzle-kit generated for the imported_at
column. This broke upgrades from v3.12.x to v3.13.0 (#228, #229).

Changes:
- Rewrite migration 0009 using table-recreation pattern (CREATE, INSERT
  SELECT, DROP, RENAME) instead of ALTER TABLE
- Add migration validation script with SQLite-specific lint rules that
  catch known invalid patterns before they ship
- Add upgrade-path testing with seeded data and verification fixtures
- Add runtime repair for users whose migration record may be stale
- Add explicit migration validation step to CI workflow

Fixes #228
Fixes #229
2026-03-15 14:10:06 +05:30
ARUNAVO RAY
755647e29c scripts: add startup repair progress logs (#223) 2026-03-14 17:44:52 +05:30
Arunavo Ray
d023b255a7 Add admin CLI password reset flow 2026-02-24 09:45:06 +05:30
Arunavo Ray
395e71164f Added basic docs on SSO/OIDC 2025-10-26 19:52:44 +05:30
Arunavo Ray
598e81ff45 updated package location 2025-08-29 17:04:48 +05:30
Arunavo Ray
e404490e75 added LFS ENV var 2025-08-28 09:26:23 +05:30
Arunavo Ray
ad7418aef2 tsc issues 2025-08-28 08:34:27 +05:30
Arunavo Ray
8dc50f7ebf Address Issue #68 and #69 2025-08-09 10:10:08 +05:30
Arunavo Ray
1e06e2bd4b Remove Auto Migrate 2025-07-19 00:28:12 +05:30
Arunavo Ray
39bfb1e2d1 Migration updates 2025-07-17 12:29:53 +05:30
Arunavo Ray
2140f75436 v3 Migration Guide 2025-07-17 12:18:23 +05:30
Arunavo Ray
beedbaf9a4 Added Encryptions to All stored token and passwords 2025-07-16 16:02:34 +05:30
Arunavo Ray
938a909787 tsc fixes 2025-07-11 01:17:54 +05:30
Arunavo Ray
fad78516ef Added SSO and OIDC 2025-07-11 01:04:50 +05:30
Arunavo Ray
6cfe43932f Fixing issues with Better Auth 2025-07-11 00:00:37 +05:30
Arunavo Ray
b838310872 Added Better Auth 2025-07-10 23:15:37 +05:30
Arunavo Ray
46cf117bdf Migrate to Drizzle kit 2025-07-10 21:44:35 +05:30
Arunavo Ray
983b47fa76 fix: update repository references from arunavo4 to RayLabsHQ 2025-07-07 10:52:33 +05:30
Arunavo Ray
d79e4fecf4 Updated Docker compose dev 2025-06-17 10:30:33 +05:30
Arunavo Ray
b1346e8c77 Updated Docs and Readme 2025-06-16 00:28:55 +05:30
Arunavo Ray
108408be81 fix: update Proxmox VE installation script references in README files 2025-06-05 23:27:56 +05:30
Arunavo Ray
ddd67faeab fix: resolve repository mirroring status inconsistencies
- Fix 'already exists, skipping migration' logic that left repositories with incorrect 'imported' status
- Update database status to 'mirrored' when repository already exists in Gitea
- Add automatic startup repair to fix existing inconsistencies on container start
- Create diagnostic and repair tools for troubleshooting mirroring issues
- Ensure consistent state between Gitea and application database

Resolves issue where repositories showed successful mirroring logs but remained
in 'imported' status, causing UI confusion and preventing proper status tracking.

Changes:
- src/lib/gitea.ts: Fixed mirrorGithubRepoToGitea() and mirrorGitHubRepoToGiteaOrg()
- docker-entrypoint.sh: Added automatic repository status repair on startup
- scripts/investigate-repo.ts: New diagnostic tool for repository analysis
- scripts/repair-mirrored-repos.ts: New repair tool with startup mode support
- scripts/cleanup-duplicate-repos.ts: New tool for removing duplicate entries

Fixes multiple user reports of misleading 'successfully mirrored' logs
while repositories remained in inconsistent state.
2025-05-28 19:58:15 +05:30
Arunavo Ray
daf4ab6a93 feat: Implement graceful shutdown and enhanced job recovery
- Added shutdown handler in docker-entrypoint.sh to manage application termination signals.
- Introduced shutdown manager to track active jobs and ensure state persistence during shutdown.
- Enhanced cleanup service to support stopping and status retrieval.
- Integrated signal handlers for proper response to termination signals (SIGTERM, SIGINT, SIGHUP).
- Updated middleware to initialize shutdown manager and cleanup service.
- Created integration tests for graceful shutdown functionality, verifying job state preservation and recovery.
- Documented graceful shutdown process and configuration in GRACEFUL_SHUTDOWN.md and SHUTDOWN_PROCESS.md.
- Added new scripts for testing shutdown behavior and cleanup.
2025-05-24 23:06:28 +05:30
Arunavo Ray
47e1c7b493 feat: Implement automatic database cleanup feature with configuration options and API support 2025-05-24 18:33:59 +05:30
Arunavo Ray
d7ce2a6908 feat: Refactor database cleanup process by removing scripts and updating documentation to use the Activity Log for event management 2025-05-24 17:58:37 +05:30
Arunavo Ray
a988be1028 feat: Implement comprehensive job recovery and resume process improvements
- Added a startup recovery script to handle interrupted jobs before application startup.
- Enhanced recovery system with database connection validation and stale job cleanup.
- Improved middleware to check for recovery needs and handle recovery during requests.
- Updated health check endpoint to include recovery system status and metrics.
- Introduced test scripts for verifying recovery functionality and job state management.
- Enhanced logging and error handling throughout the recovery process.
2025-05-24 13:45:25 +05:30
Arunavo Ray
98610482ae feat: enhance event management by adding duplicate removal, cleanup functionality, and improving activity logging 2025-05-24 13:25:58 +05:30
Arunavo Ray
7d32112369 feat: implement automatic database cleanup with cron jobs for events and mirror jobs 2025-05-23 12:15:34 +05:30
Arunavo Ray
b67473ec7e refactor: update Proxmox LXC deployment instructions and replace deprecated script 2025-05-22 20:35:18 +05:30
Arunavo Ray
abe3113755 feat: enhance job resilience with new database schema and recovery mechanisms
- Added new fields to the mirror_jobs table for job resilience, including job_type, batch_id, total_items, completed_items, item_ids, completed_item_ids, in_progress, started_at, completed_at, and last_checkpoint.
- Implemented database migration scripts to update the mirror_jobs table schema.
- Introduced processWithResilience utility for handling item processing with checkpointing and recovery capabilities.
- Updated API routes for mirroring organizations and repositories to utilize the new resilience features.
- Created recovery system to detect and resume interrupted jobs on application startup.
- Added middleware to initialize the recovery system when the server starts.
2025-05-22 14:33:03 +05:30
Arunavo Ray
8b5c5d8ed2 Update README to include event management scripts and LXC deployment details 2025-05-22 09:06:47 +05:30
Arunavo Ray
1ab642c9e7 Update LXC deployment scripts: replace installer script with Proxmox-specific script and update README references 2025-05-22 09:04:05 +05:30
Arunavo Ray
1eae725535 Update LXC deployment guide references and remove outdated documentation 2025-05-22 08:56:53 +05:30
Arunavo Ray
5bf52c806f Update README and add LXC deployment guide; enhance LXC installer scripts 2025-05-22 08:53:19 +05:30
Arunavo Ray
161685b966 Add directory permission check before creating symlink in systemd service setup 2025-05-21 22:30:15 +05:30
Arunavo Ray
0cf95b2a0e Improve error handling and permission checks in LXC installer 2025-05-21 22:26:50 +05:30
Arunavo Ray
c896194aeb Fix Bun permissions issue in LXC container installer 2025-05-21 22:19:43 +05:30
Arunavo Ray
f6b51414a0 Remove unnecessary daemon-reload from README based on PR feedback 2025-05-21 14:06:41 +05:30
Arunavo Ray
8a35c0368f Address Copilot suggestions for LXC installer improvements 2025-05-21 13:58:07 +05:30
Arunavo Ray
6f64838b55 Add LXC container support with single-command installer 2025-05-21 13:49:41 +05:30
Arunavo Ray
4aa7e665ac feat: remove Redis dependencies and cleanup scripts after migrating to SQLite 2025-05-21 11:31:22 +05:30
Arunavo Ray
04e8b817d3 feat: add event cleanup scripts and Docker Compose setup for automated maintenance 2025-05-21 02:25:05 +05:30
Arunavo Ray
6d13ff29ca feat: migrate from Redis to SQLite for event handling and notifications 2025-05-20 19:09:48 +05:30
Arunavo Ray
eb2d76a4b7 refactor: migrate database handling to Bun's SQLite and ensure data directory exists 2025-05-20 16:39:47 +05:30
ARUNAVO RAY
d5b0102080 chore: switch to bun package manager 2025-05-20 15:16:51 +05:30
Arunavo Ray
e1faea72d5 Remove database schema updates and migrations; simplify entrypoint script and related commands 2025-05-19 09:02:39 +05:30
Ankit Kr. Chowdhury
c75f05d86e Add 'mirrored_location' column to repositories table and improve warning messages in database checks 2025-05-18 14:06:07 +05:30
Arunavo Ray
5d40023de0 🎉 Gitea Mirror: Added 2025-05-18 09:31:23 +05:30