Commit Graph

4 Commits

Author SHA1 Message Date
n0mad1k 6681779552 Fix type hints and resource management in coe_mirror
- Add precise type hints: Optional[Tuple[str, str]] for _fetch_creds(),
  List[Tuple[str, str, str]] for notify()
- Wrap requests.Session in context manager for proper cleanup
- Remove unreachable return False after retry loop in _send_matrix()
2026-06-14 14:40:14 -04:00
n0mad1k 24d062fc5d Implement real Matrix notification for coe-mirror
Replace stub notify() with full Synapse integration targeting General room.
- Add _send_matrix(), _get_matrix_token(), _matrix_login() helpers
- Implement token cache with 30-min refresh threshold and 401 retry
- Fetch credentials via Infisical (MATRIX_USER, MATRIX_PASSWORD from matrix/)
- Add MATRIX_* env overrides for testing (homeserver, room, token cache path)
- Non-fatal failures: Matrix outage logs warning, does not break mirror run
- Add 5 comprehensive test cases covering success, failure, 401 refresh, env override, chmod 600
- All 18 tests passing
- Update README and notes.md with implementation details
2026-06-14 14:36:14 -04:00
Cobra 745844f721 install.sh: skip pip when requests is already system-wide
PEP 668 Debian 13 systems error out on 'pip install --user'. Runtime
only needs requests; pytest+requests-mock are test-only. Detect the
runtime dep first and fall back to pip only when missing.
2026-06-11 09:37:02 -04:00
Cobra 45a8d6163e coe-mirror: mirror Nightmare_Eclipse Forgejo repos to pCloud
Standalone Python tool. Hits git.churchofmalware.org public API every
12h (00:00/12:00), downloads any repo HEAD whose SHA hasn't already
been snapshotted to pCloud, with local-staging fallback when the FUSE
mount is unavailable. Matrix notification stub for when the home
server is back.

Devil's-advocate findings folded into the design:
  - shutil.copy2 + size verify + unlink, not os.rename, for FUSE safety
  - no pCloud daemon auto-start (no user unit; DISPLAY=:0 unreliable);
    relies on Persistent timer + pending flush for recovery
  - two-call API path retained because the repo list response does not
    include commit.sha

Audit-driven security fixes:
  - repo names whitelist-validated (^[a-zA-Z0-9._-]+$)
  - urllib.parse.quote on all interpolated URL segments
  - same-file no-op guard in place_into_pcloud
  - existence check moved to main() so cached files don't generate
    spurious notify entries

13 pytest tests passing.
2026-06-11 09:34:55 -04:00