feat(api): add hash-based duplicate checking endpoint for sync clients #25

Merged
zooper merged 1 commit from feature/sync-duplicate-api-proper into main 2025-08-12 21:38:18 +00:00
zooper commented 2025-08-12 21:35:28 +00:00 (Migrated from github.com)

🎯 Overview

Add /api/lightroom/check-duplicate endpoint to support intelligent duplicate detection for desktop sync applications like Caption Sync Qt client.

📋 Changes Made

Express Server (server.js)

  • Basic development endpoint implementation
  • Returns exists: false for all checks (dev mode)
  • Proper error handling and validation

Cloudflare Workers (worker.js)

  • Full production implementation with D1 database integration
  • Hash-based image lookup using database.getImageByHash(user.id, hash)
  • Returns existence status with image metadata

🔌 API Contract

Endpoint: GET /api/lightroom/check-duplicate?hash=<sha256>
Auth: API key via Bearer token
Response:

{
  "exists": boolean,
  "id": "string",      // if exists
  "filename": "string" // if exists  
}

🚀 Integration Benefits

  • Server-side duplicate detection for Caption Sync Qt client
  • Complements local caching with authoritative server state
  • Prevents unnecessary uploads of existing content
  • SHA256-based reliable content identification
  • User-scoped - only checks images belonging to authenticated user

🧪 Testing

  • Caption Sync Qt client successfully integrates with this endpoint
  • Prevents duplicate uploads during sync operations
  • Handles network errors and fallback gracefully

📊 Impact

  • Reduces server storage from duplicate uploads
  • Improves sync client performance
  • Provides foundation for other sync applications

Closes sync client duplicate upload functionality.

## 🎯 Overview Add `/api/lightroom/check-duplicate` endpoint to support intelligent duplicate detection for desktop sync applications like Caption Sync Qt client. ## 📋 Changes Made ### Express Server (server.js) - Basic development endpoint implementation - Returns `exists: false` for all checks (dev mode) - Proper error handling and validation ### Cloudflare Workers (worker.js) - Full production implementation with D1 database integration - Hash-based image lookup using `database.getImageByHash(user.id, hash)` - Returns existence status with image metadata ## 🔌 API Contract **Endpoint:** `GET /api/lightroom/check-duplicate?hash=<sha256>` **Auth:** API key via Bearer token **Response:** ```json { "exists": boolean, "id": "string", // if exists "filename": "string" // if exists } ``` ## 🚀 Integration Benefits - **Server-side duplicate detection** for Caption Sync Qt client - **Complements local caching** with authoritative server state - **Prevents unnecessary uploads** of existing content - **SHA256-based** reliable content identification - **User-scoped** - only checks images belonging to authenticated user ## 🧪 Testing - Caption Sync Qt client successfully integrates with this endpoint - Prevents duplicate uploads during sync operations - Handles network errors and fallback gracefully ## 📊 Impact - Reduces server storage from duplicate uploads - Improves sync client performance - Provides foundation for other sync applications Closes sync client duplicate upload functionality.
cloudflare-workers-and-pages[bot] commented 2025-08-12 21:35:36 +00:00 (Migrated from github.com)

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
Deployment successful!
View logs
ai-caption-studio 70cfa941 Commit Preview URL

Branch Preview URL
Aug 12 2025, 09:35 PM
## Deploying with &nbsp;<a href="https://workers.dev"><img alt="Cloudflare Workers" src="https://workers.cloudflare.com/logo.svg" width="16"></a> &nbsp;Cloudflare Workers The latest updates on your project. Learn more about [integrating Git with Workers](https://developers.cloudflare.com/workers/ci-cd/builds/git-integration/). | Status | Name | Latest Commit | Preview URL | Updated (UTC) | | -|-|-|-|-| | ✅ Deployment successful! <br>[View logs](https://dash.cloudflare.com/a3886cd60d9d98381472be25235a1347/workers/services/view/ai-caption-studio/production/builds/d2d9fd4d-ef9a-4ea7-86d2-5ab233a2965d) | ai-caption-studio | 70cfa941 | <a href='https://49829b46-ai-caption-studio.jonsson.workers.dev'>Commit Preview URL</a><br><br><a href='https://feature-sync-duplicate-api-proper-ai-caption-studio.jonsson.workers.dev'>Branch Preview URL</a> | Aug 12 2025, 09:35 PM |
Sign in to join this conversation.
No description provided.